@atlaskit/smart-card 16.1.0 → 16.3.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.
- package/CHANGELOG.md +58 -0
- package/dist/cjs/client/utils/environments.js +1 -1
- package/dist/cjs/extractors/block/index.js +2 -2
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/providers/editor/transformer.js +6 -2
- package/dist/cjs/state/actions/index.js +14 -7
- package/dist/cjs/state/analytics/index.js +32 -84
- package/dist/cjs/state/analytics/ufoExperiences.js +63 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +114 -0
- package/dist/cjs/state/hooks/useSmartLink.js +6 -6
- package/dist/cjs/utils/analytics/analytics.js +6 -6
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/index.js +1 -1
- package/dist/cjs/view/CardWithUrl/component-lazy/index.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +8 -3
- package/dist/cjs/view/CardWithUrl/loader.js +106 -134
- package/dist/cjs/view/EmbedCard/index.js +1 -1
- package/dist/es2019/client/utils/environments.js +1 -1
- package/dist/es2019/extractors/block/index.js +2 -2
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/providers/editor/transformer.js +4 -2
- package/dist/es2019/state/actions/index.js +10 -5
- package/dist/es2019/state/analytics/index.js +2 -40
- package/dist/es2019/state/analytics/ufoExperiences.js +43 -0
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +76 -0
- package/dist/es2019/state/hooks/useSmartLink.js +4 -5
- package/dist/es2019/utils/analytics/analytics.js +6 -6
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/index.js +2 -2
- package/dist/es2019/view/CardWithUrl/component-lazy/index.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +8 -3
- package/dist/es2019/view/CardWithUrl/loader.js +83 -92
- package/dist/es2019/view/EmbedCard/index.js +2 -2
- package/dist/esm/client/utils/environments.js +1 -1
- package/dist/esm/extractors/block/index.js +2 -2
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/providers/editor/transformer.js +6 -2
- package/dist/esm/state/actions/index.js +13 -7
- package/dist/esm/state/analytics/index.js +2 -80
- package/dist/esm/state/analytics/ufoExperiences.js +43 -0
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +102 -0
- package/dist/esm/state/hooks/useSmartLink.js +6 -6
- package/dist/esm/utils/analytics/analytics.js +6 -6
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/index.js +2 -2
- package/dist/esm/view/CardWithUrl/component-lazy/index.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +8 -3
- package/dist/esm/view/CardWithUrl/loader.js +101 -130
- package/dist/esm/view/EmbedCard/index.js +2 -2
- package/dist/types/extractors/block/types.d.ts +1 -1
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/state/analytics/index.d.ts +3 -32
- package/dist/types/state/analytics/ufoExperiences.d.ts +7 -0
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +31 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +5 -6
- package/dist/types/utils/analytics/analytics.d.ts +3 -3
- package/dist/types/view/CardWithUrl/component-lazy/index.d.ts +1 -1
- package/dist/types/view/CardWithUrl/loader.d.ts +1 -15
- package/package.json +19 -16
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, resolvedEvent as _resolvedEvent, unresolvedEvent as _unresolvedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
4
|
+
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
|
|
5
|
+
var ui = useMemo(function () {
|
|
6
|
+
return {
|
|
7
|
+
authEvent: function authEvent(display, definitionId, extensionKey) {
|
|
8
|
+
return dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey));
|
|
9
|
+
},
|
|
10
|
+
authAlternateAccountEvent: function authAlternateAccountEvent(display, definitionId, extensionKey) {
|
|
11
|
+
return dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey));
|
|
12
|
+
},
|
|
13
|
+
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey) {
|
|
14
|
+
return dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey));
|
|
15
|
+
},
|
|
16
|
+
actionClickedEvent: function actionClickedEvent(id, extensionKey, actionType, display, invokeType) {
|
|
17
|
+
startUfoExperience('smart-link-action-invocation', id, {
|
|
18
|
+
actionType: actionType,
|
|
19
|
+
display: display,
|
|
20
|
+
extensionKey: extensionKey,
|
|
21
|
+
invokeType: invokeType
|
|
22
|
+
});
|
|
23
|
+
dispatchAnalytics(uiActionClickedEvent(extensionKey, actionType, display));
|
|
24
|
+
},
|
|
25
|
+
closedAuthEvent: function closedAuthEvent(display, definitionId, extensionKey) {
|
|
26
|
+
return dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey));
|
|
27
|
+
},
|
|
28
|
+
renderSuccessEvent: function renderSuccessEvent(display, id, definitionId, extensionKey) {
|
|
29
|
+
succeedUfoExperience('smart-link-rendered', id, {
|
|
30
|
+
extensionKey: extensionKey,
|
|
31
|
+
display: display
|
|
32
|
+
}); // UFO will disregard this if authentication experience has not yet been started
|
|
33
|
+
|
|
34
|
+
succeedUfoExperience('smart-link-authenticated', id, {
|
|
35
|
+
display: display
|
|
36
|
+
});
|
|
37
|
+
dispatchAnalytics(uiRenderSuccessEvent(display, definitionId, extensionKey));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}, [dispatchAnalytics]);
|
|
41
|
+
var operational = useMemo(function () {
|
|
42
|
+
return {
|
|
43
|
+
resolvedEvent: function resolvedEvent(id, definitionId, extensionKey, resourceType) {
|
|
44
|
+
return dispatchAnalytics(_resolvedEvent(id, definitionId, extensionKey, resourceType));
|
|
45
|
+
},
|
|
46
|
+
unresolvedEvent: function unresolvedEvent(id, status, definitionId, extensionKey, resourceType) {
|
|
47
|
+
return dispatchAnalytics(_unresolvedEvent(id, status, definitionId, extensionKey, resourceType));
|
|
48
|
+
},
|
|
49
|
+
invokeSucceededEvent: function invokeSucceededEvent(id, providerKey, actionType, display) {
|
|
50
|
+
succeedUfoExperience('smart-link-action-invocation', id);
|
|
51
|
+
dispatchAnalytics(_invokeSucceededEvent(id, providerKey, actionType, display));
|
|
52
|
+
},
|
|
53
|
+
invokeFailedEvent: function invokeFailedEvent(id, providerKey, actionType, display, reason) {
|
|
54
|
+
failUfoExperience('smart-link-action-invocation', id);
|
|
55
|
+
dispatchAnalytics(_invokeFailedEvent(id, providerKey, actionType, display, reason));
|
|
56
|
+
},
|
|
57
|
+
connectSucceededEvent: function connectSucceededEvent(id, definitionId, extensionKey) {
|
|
58
|
+
startUfoExperience('smart-link-authenticated', id, {
|
|
59
|
+
extensionKey: extensionKey,
|
|
60
|
+
status: 'success'
|
|
61
|
+
});
|
|
62
|
+
dispatchAnalytics(_connectSucceededEvent(definitionId, extensionKey));
|
|
63
|
+
},
|
|
64
|
+
connectFailedEvent: function connectFailedEvent(id, definitionId, extensionKey, status) {
|
|
65
|
+
startUfoExperience('smart-link-authenticated', id, {
|
|
66
|
+
extensionKey: extensionKey,
|
|
67
|
+
status: status
|
|
68
|
+
});
|
|
69
|
+
dispatchAnalytics(_connectFailedEvent(definitionId, extensionKey, status));
|
|
70
|
+
},
|
|
71
|
+
instrument: function instrument(id, status, definitionId, extensionKey, resourceType, error) {
|
|
72
|
+
var event = instrumentEvent(id, status, definitionId, extensionKey, resourceType, error);
|
|
73
|
+
|
|
74
|
+
if (event) {
|
|
75
|
+
dispatchAnalytics(event);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}, [dispatchAnalytics]);
|
|
80
|
+
var track = useMemo(function () {
|
|
81
|
+
return {
|
|
82
|
+
appAccountConnected: function appAccountConnected(definitionId, extensionKey) {
|
|
83
|
+
return dispatchAnalytics(trackAppAccountConnected(definitionId, extensionKey));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}, [dispatchAnalytics]);
|
|
87
|
+
var screen = useMemo(function () {
|
|
88
|
+
return {
|
|
89
|
+
authPopupEvent: function authPopupEvent(definitionId, extensionKey) {
|
|
90
|
+
return dispatchAnalytics(screenAuthPopupEvent(definitionId, extensionKey));
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}, [dispatchAnalytics]);
|
|
94
|
+
return useMemo(function () {
|
|
95
|
+
return {
|
|
96
|
+
ui: ui,
|
|
97
|
+
operational: operational,
|
|
98
|
+
track: track,
|
|
99
|
+
screen: screen
|
|
100
|
+
};
|
|
101
|
+
}, [ui, operational, track, screen]);
|
|
102
|
+
};
|
|
@@ -12,16 +12,15 @@ export function useSmartLink(id, url, dispatchAnalytics) {
|
|
|
12
12
|
var config = useSmartLinkConfig();
|
|
13
13
|
var renderers = useSmartLinkRenderers(); // NB: used to propagate errors from hooks to error boundaries.
|
|
14
14
|
|
|
15
|
-
var _useState = useState(),
|
|
15
|
+
var _useState = useState(null),
|
|
16
16
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
-
|
|
17
|
+
error = _useState2[0],
|
|
18
|
+
setError = _useState2[1]; // Register the current card.
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
var register = function register() {
|
|
21
22
|
actions.register().catch(function (err) {
|
|
22
|
-
return
|
|
23
|
-
throw err;
|
|
24
|
-
});
|
|
23
|
+
return setError(err);
|
|
25
24
|
});
|
|
26
25
|
}; // AFP-2511 TODO: Fix automatic suppressions below
|
|
27
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -34,6 +33,7 @@ export function useSmartLink(id, url, dispatchAnalytics) {
|
|
|
34
33
|
actions: actions,
|
|
35
34
|
config: config,
|
|
36
35
|
analytics: analytics,
|
|
37
|
-
renderers: renderers
|
|
36
|
+
renderers: renderers,
|
|
37
|
+
error: error
|
|
38
38
|
};
|
|
39
39
|
}
|
|
@@ -82,7 +82,7 @@ export var unresolvedEvent = function unresolvedEvent(id, status, definitionId,
|
|
|
82
82
|
})
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
export var invokeSucceededEvent = function invokeSucceededEvent(id,
|
|
85
|
+
export var invokeSucceededEvent = function invokeSucceededEvent(id, extensionKey, actionType, display) {
|
|
86
86
|
var measure = getMeasure(id, 'resolved') || {
|
|
87
87
|
duration: undefined
|
|
88
88
|
};
|
|
@@ -94,12 +94,12 @@ export var invokeSucceededEvent = function invokeSucceededEvent(id, providerKey,
|
|
|
94
94
|
id: id,
|
|
95
95
|
actionType: actionType,
|
|
96
96
|
display: display,
|
|
97
|
-
|
|
97
|
+
extensionKey: extensionKey,
|
|
98
98
|
duration: measure.duration
|
|
99
99
|
})
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
-
export var invokeFailedEvent = function invokeFailedEvent(id,
|
|
102
|
+
export var invokeFailedEvent = function invokeFailedEvent(id, extensionKey, actionType, display, reason) {
|
|
103
103
|
var measure = getMeasure(id, 'errored') || {
|
|
104
104
|
duration: undefined
|
|
105
105
|
};
|
|
@@ -111,7 +111,7 @@ export var invokeFailedEvent = function invokeFailedEvent(id, providerKey, actio
|
|
|
111
111
|
id: id,
|
|
112
112
|
actionType: actionType,
|
|
113
113
|
display: display,
|
|
114
|
-
|
|
114
|
+
extensionKey: extensionKey,
|
|
115
115
|
duration: measure.duration,
|
|
116
116
|
reason: reason
|
|
117
117
|
})
|
|
@@ -194,14 +194,14 @@ export var uiCardClickedEvent = function uiCardClickedEvent(display, definitionI
|
|
|
194
194
|
})
|
|
195
195
|
};
|
|
196
196
|
};
|
|
197
|
-
export var uiActionClickedEvent = function uiActionClickedEvent(
|
|
197
|
+
export var uiActionClickedEvent = function uiActionClickedEvent(extensionKey, actionType, display) {
|
|
198
198
|
return {
|
|
199
199
|
action: 'clicked',
|
|
200
200
|
actionSubject: 'smartLinkAction',
|
|
201
201
|
eventType: 'ui',
|
|
202
202
|
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
203
203
|
display: display,
|
|
204
|
-
|
|
204
|
+
extensionKey: extensionKey,
|
|
205
205
|
actionType: actionType
|
|
206
206
|
})
|
|
207
207
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { CardLinkView, BlockCardResolvingView, BlockCardErroredView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardResolvedView, BlockCardNotFoundView, AuthorizeAction, ForbiddenAction } from '@atlaskit/media-ui';
|
|
4
|
-
import {
|
|
4
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
5
5
|
import { extractBlockProps } from '../../extractors/block';
|
|
6
6
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
7
7
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
@@ -29,7 +29,7 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
29
29
|
var extractorOpts = {
|
|
30
30
|
handleAnalytics: handlePreviewAnalytics,
|
|
31
31
|
handleInvoke: handleInvoke,
|
|
32
|
-
|
|
32
|
+
extensionKey: getExtensionKey(details)
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
switch (status) {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { isIntersectionObserverSupported } from '@atlaskit/media-ui';
|
|
3
3
|
import { LazyLazilyRenderCard } from './LazyLazilyRenderCard';
|
|
4
4
|
import { LazyIntersectionObserverCard } from './LazyIntersectionObserverCard';
|
|
5
|
-
export function LazyCardWithUrlContent(props) {
|
|
5
|
+
export default function LazyCardWithUrlContent(props) {
|
|
6
6
|
if (isIntersectionObserverSupported()) {
|
|
7
7
|
return /*#__PURE__*/React.createElement(LazyIntersectionObserverCard, props);
|
|
8
8
|
} else {
|
|
@@ -28,7 +28,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
28
28
|
actions = _useSmartLink.actions,
|
|
29
29
|
config = _useSmartLink.config,
|
|
30
30
|
analytics = _useSmartLink.analytics,
|
|
31
|
-
renderers = _useSmartLink.renderers
|
|
31
|
+
renderers = _useSmartLink.renderers,
|
|
32
|
+
error = _useSmartLink.error;
|
|
32
33
|
|
|
33
34
|
var definitionId = getDefinitionId(state.details);
|
|
34
35
|
var extensionKey = getExtensionKey(state.details);
|
|
@@ -71,9 +72,13 @@ export function CardWithUrlContent(_ref) {
|
|
|
71
72
|
|
|
72
73
|
useEffect(function () {
|
|
73
74
|
if (isFinalState(state.status)) {
|
|
74
|
-
analytics.ui.renderSuccessEvent(appearance, definitionId, extensionKey);
|
|
75
|
+
analytics.ui.renderSuccessEvent(appearance, id, definitionId, extensionKey);
|
|
75
76
|
}
|
|
76
|
-
}, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui]);
|
|
77
|
+
}, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]); // We have to keep this last to prevent hook order from being violated
|
|
78
|
+
|
|
79
|
+
if (error) {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
77
82
|
|
|
78
83
|
switch (appearance) {
|
|
79
84
|
case 'inline':
|
|
@@ -1,141 +1,112 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
|
-
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); }; }
|
|
10
|
-
|
|
11
|
-
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; } }
|
|
12
|
-
|
|
13
|
-
import React from 'react';
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
|
|
14
3
|
import uuid from 'uuid';
|
|
15
4
|
import { CardLinkView } from '@atlaskit/media-ui';
|
|
16
5
|
import { uiRenderFailedEvent, fireSmartLinkEvent } from '../../utils/analytics';
|
|
17
6
|
import { clearMarks, clearMeasures } from '../../utils/performance';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
_this.state = {
|
|
47
|
-
id: uuid()
|
|
48
|
-
};
|
|
49
|
-
return _this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
_createClass(CardWithURLRenderer, [{
|
|
53
|
-
key: "componentDidMount",
|
|
54
|
-
value: function componentDidMount() {
|
|
55
|
-
if (CardWithURLRenderer.CardContent === null) {
|
|
56
|
-
(this.props.importer || CardWithURLRenderer.moduleImporter)(this);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "componentWillUnmount",
|
|
61
|
-
value: function componentWillUnmount() {
|
|
62
|
-
var id = this.state.id;
|
|
7
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
8
|
+
import { failUfoExperience, startUfoExperience } from '../../state/analytics/ufoExperiences';
|
|
9
|
+
var LazyCardWithUrlContent = /*#__PURE__*/lazy(function () {
|
|
10
|
+
return import(
|
|
11
|
+
/* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
|
|
12
|
+
'./component-lazy/index');
|
|
13
|
+
});
|
|
14
|
+
export function CardWithURLRenderer(props) {
|
|
15
|
+
var _useState = useState(function () {
|
|
16
|
+
return uuid();
|
|
17
|
+
}),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
19
|
+
id = _useState2[0]; // Equivalent to ComponentWillMount
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
useState(function () {
|
|
23
|
+
// We want to start timing of render event only once and right at the start
|
|
24
|
+
startUfoExperience('smart-link-rendered', id);
|
|
25
|
+
});
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
// ComponentWillUnmount
|
|
28
|
+
return function () {
|
|
63
29
|
clearMarks(id);
|
|
64
30
|
clearMeasures(id);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
appearance = _this$props2.appearance,
|
|
89
|
-
isSelected = _this$props2.isSelected,
|
|
90
|
-
isFrameVisible = _this$props2.isFrameVisible,
|
|
91
|
-
onClick = _this$props2.onClick,
|
|
92
|
-
container = _this$props2.container,
|
|
93
|
-
onResolve = _this$props2.onResolve,
|
|
94
|
-
testId = _this$props2.testId,
|
|
95
|
-
showActions = _this$props2.showActions,
|
|
96
|
-
inheritDimensions = _this$props2.inheritDimensions,
|
|
97
|
-
platform = _this$props2.platform,
|
|
98
|
-
embedIframeRef = _this$props2.embedIframeRef,
|
|
99
|
-
inlinePreloaderStyle = _this$props2.inlinePreloaderStyle;
|
|
100
|
-
|
|
101
|
-
if (!url) {
|
|
102
|
-
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
31
|
+
};
|
|
32
|
+
}, [id]);
|
|
33
|
+
var url = props.url,
|
|
34
|
+
appearance = props.appearance,
|
|
35
|
+
isSelected = props.isSelected,
|
|
36
|
+
isFrameVisible = props.isFrameVisible,
|
|
37
|
+
onClick = props.onClick,
|
|
38
|
+
container = props.container,
|
|
39
|
+
onResolve = props.onResolve,
|
|
40
|
+
testId = props.testId,
|
|
41
|
+
showActions = props.showActions,
|
|
42
|
+
inheritDimensions = props.inheritDimensions,
|
|
43
|
+
platform = props.platform,
|
|
44
|
+
embedIframeRef = props.embedIframeRef,
|
|
45
|
+
inlinePreloaderStyle = props.inlinePreloaderStyle,
|
|
46
|
+
createAnalyticsEvent = props.createAnalyticsEvent; // Wrapper around analytics.
|
|
47
|
+
|
|
48
|
+
var dispatchAnalytics = useCallback(function (analyticsPayload) {
|
|
49
|
+
if (analyticsPayload && analyticsPayload.attributes) {
|
|
50
|
+
// Update if we haven't already set the display - possible
|
|
51
|
+
// in the case of `preview` which is rendered differently.
|
|
52
|
+
if (!analyticsPayload.attributes.display) {
|
|
53
|
+
analyticsPayload.attributes.display = appearance;
|
|
103
54
|
}
|
|
104
|
-
|
|
105
|
-
return CardWithURLRenderer.CardContent !== null ? /*#__PURE__*/React.createElement(CardWithURLRenderer.CardContent, {
|
|
106
|
-
id: this.state.id,
|
|
107
|
-
url: url,
|
|
108
|
-
appearance: appearance,
|
|
109
|
-
onClick: onClick,
|
|
110
|
-
isSelected: isSelected,
|
|
111
|
-
isFrameVisible: isFrameVisible,
|
|
112
|
-
dispatchAnalytics: this.dispatchAnalytics,
|
|
113
|
-
container: container,
|
|
114
|
-
onResolve: onResolve,
|
|
115
|
-
testId: testId,
|
|
116
|
-
showActions: showActions,
|
|
117
|
-
inheritDimensions: inheritDimensions,
|
|
118
|
-
platform: platform,
|
|
119
|
-
embedIframeRef: embedIframeRef,
|
|
120
|
-
inlinePreloaderStyle: inlinePreloaderStyle
|
|
121
|
-
}) : /*#__PURE__*/React.createElement(CardLinkView, {
|
|
122
|
-
key: 'chunk-placeholder',
|
|
123
|
-
link: url
|
|
124
|
-
});
|
|
125
55
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
56
|
+
|
|
57
|
+
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
58
|
+
}, [appearance, createAnalyticsEvent]);
|
|
59
|
+
var logError = useCallback(function (error, info) {
|
|
60
|
+
var componentStack = info.componentStack; // NB: APIErrors are thrown in response to Object Resolver Service.
|
|
61
|
+
// In these cases, control is handed back to the Editor. We do not
|
|
62
|
+
// fire an event for these, as they do not cover failed UI render events.
|
|
63
|
+
|
|
64
|
+
if (error.name === 'APIError') {
|
|
65
|
+
throw error;
|
|
66
|
+
} // NB: the rest of the errors caught here are unexpected, and correlate
|
|
67
|
+
// to the reliability of the smart-card front-end components. We instrument
|
|
68
|
+
// these in order to measure our front-end reliability.
|
|
69
|
+
else {
|
|
70
|
+
var errorInfo = {
|
|
71
|
+
componentStack: componentStack
|
|
72
|
+
};
|
|
73
|
+
failUfoExperience('smart-link-rendered', id);
|
|
74
|
+
failUfoExperience('smart-link-authenticated', id);
|
|
75
|
+
dispatchAnalytics(uiRenderFailedEvent(appearance, error, errorInfo));
|
|
135
76
|
}
|
|
136
|
-
}]);
|
|
77
|
+
}, [appearance, dispatchAnalytics, id]);
|
|
137
78
|
|
|
138
|
-
|
|
139
|
-
|
|
79
|
+
if (!url) {
|
|
80
|
+
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
81
|
+
}
|
|
140
82
|
|
|
141
|
-
|
|
83
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
84
|
+
FallbackComponent: ErrorFallback,
|
|
85
|
+
onError: logError
|
|
86
|
+
}, /*#__PURE__*/React.createElement(Suspense, {
|
|
87
|
+
fallback: /*#__PURE__*/React.createElement(CardLinkView, {
|
|
88
|
+
key: 'chunk-placeholder',
|
|
89
|
+
link: url
|
|
90
|
+
})
|
|
91
|
+
}, /*#__PURE__*/React.createElement(LazyCardWithUrlContent, {
|
|
92
|
+
id: id,
|
|
93
|
+
url: url,
|
|
94
|
+
appearance: appearance,
|
|
95
|
+
onClick: onClick,
|
|
96
|
+
isSelected: isSelected,
|
|
97
|
+
isFrameVisible: isFrameVisible,
|
|
98
|
+
dispatchAnalytics: dispatchAnalytics,
|
|
99
|
+
container: container,
|
|
100
|
+
onResolve: onResolve,
|
|
101
|
+
testId: testId,
|
|
102
|
+
showActions: showActions,
|
|
103
|
+
inheritDimensions: inheritDimensions,
|
|
104
|
+
platform: platform,
|
|
105
|
+
embedIframeRef: embedIframeRef,
|
|
106
|
+
inlinePreloaderStyle: inlinePreloaderStyle
|
|
107
|
+
})));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
var ErrorFallback = function ErrorFallback() {
|
|
111
|
+
return /*#__PURE__*/React.createElement("span", null);
|
|
112
|
+
};
|
|
@@ -6,7 +6,7 @@ import { extractEmbedProps } from '../../extractors/embed';
|
|
|
6
6
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
7
7
|
import { extractInlineProps } from '../../extractors/inline';
|
|
8
8
|
import { extractBlockProps } from '../../extractors/block';
|
|
9
|
-
import {
|
|
9
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
10
10
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
11
11
|
export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef) {
|
|
12
12
|
var _details$meta, _forbiddenViewProps$c;
|
|
@@ -73,7 +73,7 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
73
73
|
var resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
74
74
|
handleAnalytics: handleAnalytics,
|
|
75
75
|
handleInvoke: handleInvoke,
|
|
76
|
-
|
|
76
|
+
extensionKey: getExtensionKey(details)
|
|
77
77
|
});
|
|
78
78
|
return /*#__PURE__*/React.createElement(BlockCardResolvedView, _extends({}, resolvedBlockViewProps, {
|
|
79
79
|
isSelected: isSelected,
|
|
@@ -2,4 +2,4 @@ import { BlockCardResolvedViewProps } from '@atlaskit/media-ui';
|
|
|
2
2
|
import { JsonLd } from 'json-ld-types';
|
|
3
3
|
import { InvokeHandler } from '../../../model/invoke-handler';
|
|
4
4
|
import { AnalyticsHandler } from '../../../utils/types';
|
|
5
|
-
export declare const extractPreviewAction: (
|
|
5
|
+
export declare const extractPreviewAction: (extensionKey: string | undefined, viewProps: BlockCardResolvedViewProps, jsonLd: JsonLd.Data.BaseData, handleInvoke: InvokeHandler, handleAnalytics: AnalyticsHandler, testId?: string | undefined, platform?: "web" | "mobile" | undefined) => import("@atlaskit/media-ui").ActionProps | undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,5 +14,5 @@ export { EmbedResizeMessageListener } from './view/EmbedCard/EmbedResizeMessageL
|
|
|
14
14
|
export { embedHeaderHeight } from '@atlaskit/media-ui/embeds';
|
|
15
15
|
export { SmartLinkEvents } from './utils/analytics/analytics';
|
|
16
16
|
export { useSmartLinkEvents } from './view/SmartLinkEvents/useSmartLinkEvents';
|
|
17
|
-
export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName, } from '@atlaskit/media-ui/classNames';
|
|
17
|
+
export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName, blockCardResolvedViewByClassName, blockCardForbiddenViewLinkClassName, blockCardContentClassName, blockCardContentHeaderClassName, blockCardContentHeaderNameClassName, blockCardNotFoundViewClassName, blockCardErroredViewClassName, } from '@atlaskit/media-ui/classNames';
|
|
18
18
|
export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback';
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { CardType } from '../store/types';
|
|
5
|
-
import { APIError } from '../../client/errors';
|
|
6
|
-
export declare const useSmartLinkAnalytics: (dispatchAnalytics: AnalyticsHandler) => {
|
|
7
|
-
ui: {
|
|
8
|
-
authEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
9
|
-
authAlternateAccountEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
10
|
-
cardClickedEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
11
|
-
actionClickedEvent: (providerKey: string, actionType: string, display?: "inline" | "block" | "embed" | "preview" | undefined) => void;
|
|
12
|
-
closedAuthEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
13
|
-
renderSuccessEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
14
|
-
renderFailedEvent: (display: CardInnerAppearance, error: Error, errorInfo: ErrorInfo) => void;
|
|
15
|
-
};
|
|
16
|
-
operational: {
|
|
17
|
-
resolvedEvent: (id: string, definitionId?: string | undefined, extensionKey?: string | undefined, resourceType?: string | undefined) => void;
|
|
18
|
-
unresolvedEvent: (id: string, status: string, definitionId?: string | undefined, extensionKey?: string | undefined, resourceType?: string | undefined) => void;
|
|
19
|
-
invokeSucceededEvent: (id: string, providerKey: string, actionType: string, display: CardInnerAppearance) => void;
|
|
20
|
-
invokeFailedEvent: (id: string, providerKey: string, actionType: string, display: CardInnerAppearance, reason: string) => void;
|
|
21
|
-
connectSucceededEvent: (definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
22
|
-
connectFailedEvent: (definitionId?: string | undefined, extensionKey?: string | undefined, reason?: string | undefined) => void;
|
|
23
|
-
instrument: (id: string, status: CardType, definitionId?: string | undefined, extensionKey?: string | undefined, resourceType?: string | undefined, error?: APIError | undefined) => void;
|
|
24
|
-
};
|
|
25
|
-
track: {
|
|
26
|
-
appAccountConnected: (definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
27
|
-
};
|
|
28
|
-
screen: {
|
|
29
|
-
authPopupEvent: (definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export declare type AnalyticsFacade = ReturnType<typeof useSmartLinkAnalytics>;
|
|
1
|
+
export { startUfoExperience, succeedUfoExperience, failUfoExperience, addMetadataToExperience, } from './ufoExperiences';
|
|
2
|
+
export { useSmartLinkAnalytics } from './useSmartLinkAnalytics';
|
|
3
|
+
export type { AnalyticsFacade } from './useSmartLinkAnalytics';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CustomData } from '@atlaskit/ufo';
|
|
2
|
+
declare type UfoExperienceName = 'smart-link-rendered' | 'smart-link-authenticated' | 'smart-link-action-invocation';
|
|
3
|
+
export declare const startUfoExperience: (experienceName: UfoExperienceName, id: string, properties?: CustomData | undefined) => void;
|
|
4
|
+
export declare const succeedUfoExperience: (experienceName: UfoExperienceName, id: string, properties?: CustomData | undefined) => void;
|
|
5
|
+
export declare const failUfoExperience: (experienceName: UfoExperienceName, id: string, properties?: CustomData | undefined) => void;
|
|
6
|
+
export declare const addMetadataToExperience: (experienceName: UfoExperienceName, id: string, properties: CustomData) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AnalyticsHandler } from '../../utils/types';
|
|
2
|
+
import { CardInnerAppearance } from '../../view/Card/types';
|
|
3
|
+
import { CardType } from '../store/types';
|
|
4
|
+
import { APIError } from '../../client/errors';
|
|
5
|
+
import { InvokeType } from '../../model/invoke-opts';
|
|
6
|
+
export declare const useSmartLinkAnalytics: (dispatchAnalytics: AnalyticsHandler) => {
|
|
7
|
+
ui: {
|
|
8
|
+
authEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
9
|
+
authAlternateAccountEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
10
|
+
cardClickedEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
11
|
+
actionClickedEvent: (id: string, extensionKey: string, actionType: string, display: CardInnerAppearance, invokeType: InvokeType) => void;
|
|
12
|
+
closedAuthEvent: (display: CardInnerAppearance, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
13
|
+
renderSuccessEvent: (display: CardInnerAppearance, id: string, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
14
|
+
};
|
|
15
|
+
operational: {
|
|
16
|
+
resolvedEvent: (id: string, definitionId?: string | undefined, extensionKey?: string | undefined, resourceType?: string | undefined) => void;
|
|
17
|
+
unresolvedEvent: (id: string, status: string, definitionId?: string | undefined, extensionKey?: string | undefined, resourceType?: string | undefined) => void;
|
|
18
|
+
invokeSucceededEvent: (id: string, providerKey: string, actionType: string, display: CardInnerAppearance) => void;
|
|
19
|
+
invokeFailedEvent: (id: string, providerKey: string, actionType: string, display: CardInnerAppearance, reason: string) => void;
|
|
20
|
+
connectSucceededEvent: (id: string, definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
21
|
+
connectFailedEvent: (id: string, definitionId?: string | undefined, extensionKey?: string | undefined, status?: string | undefined) => void;
|
|
22
|
+
instrument: (id: string, status: CardType, definitionId?: string | undefined, extensionKey?: string | undefined, resourceType?: string | undefined, error?: APIError | undefined) => void;
|
|
23
|
+
};
|
|
24
|
+
track: {
|
|
25
|
+
appAccountConnected: (definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
26
|
+
};
|
|
27
|
+
screen: {
|
|
28
|
+
authPopupEvent: (definitionId?: string | undefined, extensionKey?: string | undefined) => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare type AnalyticsFacade = ReturnType<typeof useSmartLinkAnalytics>;
|