@atlaskit/smart-card 44.19.1 → 44.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 44.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 44.20.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`94ca4284e9ee1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/94ca4284e9ee1) -
14
+ Adds gated post-auth Rovo Chat onboarding for Google Drive SmartLinks. After a successful GDrive
15
+ SmartLink auth, eligible treatment users see Rovo Chat open as a mini-modal with the authenticated
16
+ GDrive URL provided as context and no prompt auto-sent.
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 44.19.1
4
23
 
5
24
  ### Patch Changes
@@ -14,14 +14,47 @@ var _linkingCommon = require("@atlaskit/linking-common");
14
14
  var _outboundAuthFlowClient = require("@atlaskit/outbound-auth-flow-client");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
16
  var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
17
+ var _postMessageToPubsub = require("@atlaskit/rovo-triggers/post-message-to-pubsub");
18
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
19
  var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
18
20
  var _constants = require("../../constants");
19
21
  var _utils = require("../../utils");
22
+ var _rovo = require("../../utils/rovo");
20
23
  var _analytics = require("../analytics");
21
24
  var _helpers = require("../helpers");
22
25
  var _useActionFlags = _interopRequireDefault(require("../hooks/use-action-flags"));
23
26
  var _useInvokeClientAction = _interopRequireDefault(require("../hooks/use-invoke-client-action"));
24
27
  var _useResolve = _interopRequireDefault(require("../hooks/use-resolve"));
28
+ var POST_AUTH_CHAT_EXTENSION_KEY = 'google-object-provider';
29
+ var SMART_LINK_TO_ROVO_SOURCE = 'smart-link';
30
+ var sendPostAuthChatOpenMessage = function sendPostAuthChatOpenMessage(url) {
31
+ var payload = {
32
+ type: 'chat-new',
33
+ source: SMART_LINK_TO_ROVO_SOURCE,
34
+ data: {
35
+ dialogues: [],
36
+ mode: {
37
+ useCurrentPageContext: false
38
+ },
39
+ aiFeatureContext: {
40
+ projectContext: {
41
+ projectId: url,
42
+ // Use the URL as projectName to avoid introducing a hardcoded
43
+ // user-facing provider label in Smart Card.
44
+ projectName: url,
45
+ projectUrl: url
46
+ }
47
+ }
48
+ },
49
+ openChat: true,
50
+ openChatMode: 'mini-modal'
51
+ };
52
+ window.parent.postMessage({
53
+ eventType: _postMessageToPubsub.ROVO_POST_MESSAGE_EVENT_TYPE,
54
+ payload: payload,
55
+ payloadId: crypto.randomUUID()
56
+ }, '*');
57
+ };
25
58
  var useSmartCardActions = exports.useSmartCardActions = function useSmartCardActions(id, url) {
26
59
  var resolveUrl = (0, _useResolve.default)();
27
60
  var invokeClientAction = (0, _useInvokeClientAction.default)({});
@@ -30,7 +63,10 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
30
63
  var useActionFlagsGated = (0, _platformFeatureFlagsReact.functionWithFG)('platform_sl_connect_account_flag', _useActionFlags.default, _utils.noop);
31
64
  var flags = useActionFlagsGated();
32
65
  var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
33
- store = _useSmartLinkContext.store;
66
+ store = _useSmartLinkContext.store,
67
+ rovoOptions = _useSmartLinkContext.rovoOptions;
68
+ var rovoOptionsRef = (0, _react.useRef)(rovoOptions);
69
+ rovoOptionsRef.current = rovoOptions;
34
70
  var getState = store.getState,
35
71
  dispatch = store.dispatch;
36
72
  var getSmartLinkState = (0, _react.useCallback)(function () {
@@ -108,6 +144,7 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
108
144
  status = _getSmartLinkState4.status;
109
145
  var definitionId = (0, _helpers.getDefinitionId)(details);
110
146
  var extensionKey = (0, _helpers.getExtensionKey)(details);
147
+ var isSupportedPostAuthChatExtensionKey = extensionKey === POST_AUTH_CHAT_EXTENSION_KEY;
111
148
  var services = (0, _helpers.getServices)(details);
112
149
  // When authentication is triggered, let GAS know!
113
150
  if (status === 'unauthorized') {
@@ -145,6 +182,20 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
145
182
  });
146
183
  }
147
184
  reload();
185
+
186
+ // Post-auth Chat onboarding: auto-open Rovo Chat mini-modal with the
187
+ // authed 3P link as context, for supported providers (e.g. Google Drive).
188
+ // Provider eligibility is derived from the pre-auth SmartLink state.
189
+ var isEligibleForPostAuthChat = status === 'unauthorized' && isSupportedPostAuthChatExtensionKey && (0, _platformFeatureFlags.fg)('platform_sl_3p_post_auth_chat_open_fg') && (0, _rovo.getIsRovoChatEnabled)(rovoOptionsRef.current);
190
+ if (isEligibleForPostAuthChat) {
191
+ // Experiment check: fires exposure for both control and treatment.
192
+ // Only reached after eligibility preconditions + kill switch pass, so
193
+ // exposure is counted for the triggered eligible pool.
194
+ var isEnabled = (0, _expValEquals.expValEquals)('platform_sl_3p_post_auth_chat_open_exp', 'isEnabled', true);
195
+ if (isEnabled) {
196
+ sendPostAuthChatOpenMessage(url);
197
+ }
198
+ }
148
199
  }, function (err) {
149
200
  var _err$type;
150
201
  (0, _analytics.startUfoExperience)('smart-link-authenticated', id, {
@@ -164,7 +215,7 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
164
215
  reload();
165
216
  });
166
217
  }
167
- }, [getSmartLinkState, id, reload, fireEvent, flags]);
218
+ }, [getSmartLinkState, id, reload, fireEvent, flags, url]);
168
219
  var invoke = (0, _react.useCallback)( /*#__PURE__*/function () {
169
220
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(opts, appearance) {
170
221
  var key, action, source;
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
11
11
  var context = exports.context = {
12
12
  componentName: 'smart-cards',
13
13
  packageName: "@atlaskit/smart-card" || '',
14
- packageVersion: "44.19.0" || ''
14
+ packageVersion: "44.20.0" || ''
15
15
  };
16
16
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
17
17
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -19,7 +19,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
19
19
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
20
20
  var PACKAGE_DATA = {
21
21
  packageName: "@atlaskit/smart-card",
22
- packageVersion: "44.19.0",
22
+ packageVersion: "44.20.0",
23
23
  componentName: 'linkUrl'
24
24
  };
25
25
  var LinkUrl = function LinkUrl(_ref) {
@@ -1,18 +1,51 @@
1
- import { useCallback, useMemo } from 'react';
1
+ import { useCallback, useMemo, useRef } from 'react';
2
2
  import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
3
3
  import { useSmartLinkContext } from '@atlaskit/link-provider';
4
4
  import { ACTION_RESOLVING, ACTION_UPDATE_METADATA_STATUS, cardAction } from '@atlaskit/linking-common';
5
5
  import { auth } from '@atlaskit/outbound-auth-flow-client';
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
7
  import { functionWithFG } from '@atlaskit/platform-feature-flags-react';
8
+ import { ROVO_POST_MESSAGE_EVENT_TYPE } from '@atlaskit/rovo-triggers/post-message-to-pubsub';
9
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
10
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
9
11
  import { SmartLinkStatus } from '../../constants';
10
12
  import { noop } from '../../utils';
13
+ import { getIsRovoChatEnabled } from '../../utils/rovo';
11
14
  import { startUfoExperience } from '../analytics';
12
15
  import { getByDefinitionId, getDefinitionId, getExtensionKey, getServices } from '../helpers';
13
16
  import useActionFlags from '../hooks/use-action-flags';
14
17
  import useInvokeClientAction from '../hooks/use-invoke-client-action';
15
18
  import useResolve from '../hooks/use-resolve';
19
+ const POST_AUTH_CHAT_EXTENSION_KEY = 'google-object-provider';
20
+ const SMART_LINK_TO_ROVO_SOURCE = 'smart-link';
21
+ const sendPostAuthChatOpenMessage = url => {
22
+ const payload = {
23
+ type: 'chat-new',
24
+ source: SMART_LINK_TO_ROVO_SOURCE,
25
+ data: {
26
+ dialogues: [],
27
+ mode: {
28
+ useCurrentPageContext: false
29
+ },
30
+ aiFeatureContext: {
31
+ projectContext: {
32
+ projectId: url,
33
+ // Use the URL as projectName to avoid introducing a hardcoded
34
+ // user-facing provider label in Smart Card.
35
+ projectName: url,
36
+ projectUrl: url
37
+ }
38
+ }
39
+ },
40
+ openChat: true,
41
+ openChatMode: 'mini-modal'
42
+ };
43
+ window.parent.postMessage({
44
+ eventType: ROVO_POST_MESSAGE_EVENT_TYPE,
45
+ payload,
46
+ payloadId: crypto.randomUUID()
47
+ }, '*');
48
+ };
16
49
  export const useSmartCardActions = (id, url) => {
17
50
  const resolveUrl = useResolve();
18
51
  const invokeClientAction = useInvokeClientAction({});
@@ -22,8 +55,11 @@ export const useSmartCardActions = (id, url) => {
22
55
  const useActionFlagsGated = functionWithFG('platform_sl_connect_account_flag', useActionFlags, noop);
23
56
  const flags = useActionFlagsGated();
24
57
  const {
25
- store
58
+ store,
59
+ rovoOptions
26
60
  } = useSmartLinkContext();
61
+ const rovoOptionsRef = useRef(rovoOptions);
62
+ rovoOptionsRef.current = rovoOptions;
27
63
  const {
28
64
  getState,
29
65
  dispatch
@@ -89,6 +125,7 @@ export const useSmartCardActions = (id, url) => {
89
125
  } = getSmartLinkState();
90
126
  const definitionId = getDefinitionId(details);
91
127
  const extensionKey = getExtensionKey(details);
128
+ const isSupportedPostAuthChatExtensionKey = extensionKey === POST_AUTH_CHAT_EXTENSION_KEY;
92
129
  const services = getServices(details);
93
130
  // When authentication is triggered, let GAS know!
94
131
  if (status === 'unauthorized') {
@@ -126,6 +163,20 @@ export const useSmartCardActions = (id, url) => {
126
163
  });
127
164
  }
128
165
  reload();
166
+
167
+ // Post-auth Chat onboarding: auto-open Rovo Chat mini-modal with the
168
+ // authed 3P link as context, for supported providers (e.g. Google Drive).
169
+ // Provider eligibility is derived from the pre-auth SmartLink state.
170
+ const isEligibleForPostAuthChat = status === 'unauthorized' && isSupportedPostAuthChatExtensionKey && fg('platform_sl_3p_post_auth_chat_open_fg') && getIsRovoChatEnabled(rovoOptionsRef.current);
171
+ if (isEligibleForPostAuthChat) {
172
+ // Experiment check: fires exposure for both control and treatment.
173
+ // Only reached after eligibility preconditions + kill switch pass, so
174
+ // exposure is counted for the triggered eligible pool.
175
+ const isEnabled = expValEquals('platform_sl_3p_post_auth_chat_open_exp', 'isEnabled', true);
176
+ if (isEnabled) {
177
+ sendPostAuthChatOpenMessage(url);
178
+ }
179
+ }
129
180
  }, err => {
130
181
  var _err$type;
131
182
  startUfoExperience('smart-link-authenticated', id, {
@@ -145,7 +196,7 @@ export const useSmartCardActions = (id, url) => {
145
196
  reload();
146
197
  });
147
198
  }
148
- }, [getSmartLinkState, id, reload, fireEvent, flags]);
199
+ }, [getSmartLinkState, id, reload, fireEvent, flags, url]);
149
200
  const invoke = useCallback(async (opts, appearance) => {
150
201
  const {
151
202
  key,
@@ -2,7 +2,7 @@ export const ANALYTICS_CHANNEL = 'media';
2
2
  export const context = {
3
3
  componentName: 'smart-cards',
4
4
  packageName: "@atlaskit/smart-card" || '',
5
- packageVersion: "44.19.0" || ''
5
+ packageVersion: "44.20.0" || ''
6
6
  };
7
7
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
8
8
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -9,7 +9,7 @@ import LinkWarningModal from './LinkWarningModal';
9
9
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
10
10
  const PACKAGE_DATA = {
11
11
  packageName: "@atlaskit/smart-card",
12
- packageVersion: "44.19.0",
12
+ packageVersion: "44.20.0",
13
13
  componentName: 'linkUrl'
14
14
  };
15
15
  const LinkUrl = ({
@@ -1,20 +1,53 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { useCallback, useMemo } from 'react';
3
+ import { useCallback, useMemo, useRef } from 'react';
4
4
  import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
5
5
  import { useSmartLinkContext } from '@atlaskit/link-provider';
6
6
  import { ACTION_RESOLVING, ACTION_UPDATE_METADATA_STATUS, cardAction } from '@atlaskit/linking-common';
7
7
  import { auth } from '@atlaskit/outbound-auth-flow-client';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { functionWithFG } from '@atlaskit/platform-feature-flags-react';
10
+ import { ROVO_POST_MESSAGE_EVENT_TYPE } from '@atlaskit/rovo-triggers/post-message-to-pubsub';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
12
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
11
13
  import { SmartLinkStatus } from '../../constants';
12
14
  import { noop } from '../../utils';
15
+ import { getIsRovoChatEnabled } from '../../utils/rovo';
13
16
  import { startUfoExperience } from '../analytics';
14
17
  import { getByDefinitionId, getDefinitionId, getExtensionKey, getServices } from '../helpers';
15
18
  import useActionFlags from '../hooks/use-action-flags';
16
19
  import useInvokeClientAction from '../hooks/use-invoke-client-action';
17
20
  import useResolve from '../hooks/use-resolve';
21
+ var POST_AUTH_CHAT_EXTENSION_KEY = 'google-object-provider';
22
+ var SMART_LINK_TO_ROVO_SOURCE = 'smart-link';
23
+ var sendPostAuthChatOpenMessage = function sendPostAuthChatOpenMessage(url) {
24
+ var payload = {
25
+ type: 'chat-new',
26
+ source: SMART_LINK_TO_ROVO_SOURCE,
27
+ data: {
28
+ dialogues: [],
29
+ mode: {
30
+ useCurrentPageContext: false
31
+ },
32
+ aiFeatureContext: {
33
+ projectContext: {
34
+ projectId: url,
35
+ // Use the URL as projectName to avoid introducing a hardcoded
36
+ // user-facing provider label in Smart Card.
37
+ projectName: url,
38
+ projectUrl: url
39
+ }
40
+ }
41
+ },
42
+ openChat: true,
43
+ openChatMode: 'mini-modal'
44
+ };
45
+ window.parent.postMessage({
46
+ eventType: ROVO_POST_MESSAGE_EVENT_TYPE,
47
+ payload: payload,
48
+ payloadId: crypto.randomUUID()
49
+ }, '*');
50
+ };
18
51
  export var useSmartCardActions = function useSmartCardActions(id, url) {
19
52
  var resolveUrl = useResolve();
20
53
  var invokeClientAction = useInvokeClientAction({});
@@ -23,7 +56,10 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
23
56
  var useActionFlagsGated = functionWithFG('platform_sl_connect_account_flag', useActionFlags, noop);
24
57
  var flags = useActionFlagsGated();
25
58
  var _useSmartLinkContext = useSmartLinkContext(),
26
- store = _useSmartLinkContext.store;
59
+ store = _useSmartLinkContext.store,
60
+ rovoOptions = _useSmartLinkContext.rovoOptions;
61
+ var rovoOptionsRef = useRef(rovoOptions);
62
+ rovoOptionsRef.current = rovoOptions;
27
63
  var getState = store.getState,
28
64
  dispatch = store.dispatch;
29
65
  var getSmartLinkState = useCallback(function () {
@@ -101,6 +137,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
101
137
  status = _getSmartLinkState4.status;
102
138
  var definitionId = getDefinitionId(details);
103
139
  var extensionKey = getExtensionKey(details);
140
+ var isSupportedPostAuthChatExtensionKey = extensionKey === POST_AUTH_CHAT_EXTENSION_KEY;
104
141
  var services = getServices(details);
105
142
  // When authentication is triggered, let GAS know!
106
143
  if (status === 'unauthorized') {
@@ -138,6 +175,20 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
138
175
  });
139
176
  }
140
177
  reload();
178
+
179
+ // Post-auth Chat onboarding: auto-open Rovo Chat mini-modal with the
180
+ // authed 3P link as context, for supported providers (e.g. Google Drive).
181
+ // Provider eligibility is derived from the pre-auth SmartLink state.
182
+ var isEligibleForPostAuthChat = status === 'unauthorized' && isSupportedPostAuthChatExtensionKey && fg('platform_sl_3p_post_auth_chat_open_fg') && getIsRovoChatEnabled(rovoOptionsRef.current);
183
+ if (isEligibleForPostAuthChat) {
184
+ // Experiment check: fires exposure for both control and treatment.
185
+ // Only reached after eligibility preconditions + kill switch pass, so
186
+ // exposure is counted for the triggered eligible pool.
187
+ var isEnabled = expValEquals('platform_sl_3p_post_auth_chat_open_exp', 'isEnabled', true);
188
+ if (isEnabled) {
189
+ sendPostAuthChatOpenMessage(url);
190
+ }
191
+ }
141
192
  }, function (err) {
142
193
  var _err$type;
143
194
  startUfoExperience('smart-link-authenticated', id, {
@@ -157,7 +208,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
157
208
  reload();
158
209
  });
159
210
  }
160
- }, [getSmartLinkState, id, reload, fireEvent, flags]);
211
+ }, [getSmartLinkState, id, reload, fireEvent, flags, url]);
161
212
  var invoke = useCallback( /*#__PURE__*/function () {
162
213
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(opts, appearance) {
163
214
  var key, action, source;
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
4
4
  export var context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card" || '',
7
- packageVersion: "44.19.0" || ''
7
+ packageVersion: "44.20.0" || ''
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
12
12
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
13
13
  var PACKAGE_DATA = {
14
14
  packageName: "@atlaskit/smart-card",
15
- packageVersion: "44.19.0",
15
+ packageVersion: "44.20.0",
16
16
  componentName: 'linkUrl'
17
17
  };
18
18
  var LinkUrl = function LinkUrl(_ref) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "44.19.1",
3
+ "version": "44.20.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -78,7 +78,7 @@
78
78
  "@atlaskit/popup": "^4.23.0",
79
79
  "@atlaskit/primitives": "^19.0.0",
80
80
  "@atlaskit/react-ufo": "^6.6.0",
81
- "@atlaskit/rovo-triggers": "^6.5.0",
81
+ "@atlaskit/rovo-triggers": "^7.1.0",
82
82
  "@atlaskit/section-message": "^8.13.0",
83
83
  "@atlaskit/select": "^21.12.0",
84
84
  "@atlaskit/spinner": "^19.1.0",
@@ -87,7 +87,7 @@
87
87
  "@atlaskit/textfield": "^8.3.0",
88
88
  "@atlaskit/theme": "^25.0.0",
89
89
  "@atlaskit/tile": "^1.1.0",
90
- "@atlaskit/tmp-editor-statsig": "^86.0.0",
90
+ "@atlaskit/tmp-editor-statsig": "^87.0.0",
91
91
  "@atlaskit/tokens": "^13.1.0",
92
92
  "@atlaskit/tooltip": "^22.5.0",
93
93
  "@atlaskit/ufo": "^0.5.0",
@@ -279,6 +279,9 @@
279
279
  },
280
280
  "navx-4957-sl-embed-modal-a11y-label": {
281
281
  "type": "boolean"
282
+ },
283
+ "platform_sl_3p_post_auth_chat_open_fg": {
284
+ "type": "boolean"
282
285
  }
283
286
  },
284
287
  "compassUnitTestMetricSourceId": "ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:metric-source/c5751cc6-3513-4070-9deb-af31e86aed34/f74ef1bc-7240-4aac-9dc8-9dc43b502089"