@atlaskit/rovo-triggers 10.26.2 → 10.28.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/rovo-triggers
2
2
 
3
+ ## 10.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`adcb94adde065`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/adcb94adde065) -
8
+ Accept an optional `rovoJourneyId` on the chat-new pub/sub payload and bind it to the Chat
9
+ conversation created for a Quick Find handoff. Emit it only on `message sent`,
10
+ `aiMateActions displayed`, `aiInteraction initiated`, `aiResult viewed`, and `aiResult actioned`
11
+ events, stripping it from every other analytics event even when a caller explicitly supplies it.
12
+
13
+ ## 10.27.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [`2d5202d1360a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2d5202d1360a6) -
18
+ Add an optional `historyMode` option to `updatePageRovoParams` so callers that consume (remove)
19
+ Rovo URL parameters can replace the current history entry instead of pushing a new one. Adding
20
+ parameters continues to push, so opening chat still leaves the originating page in history.
21
+ Consumed `prompt` and `conversationId` cleanup now opts into replacement, so Back returns to the
22
+ originating page. Gated behind rovo_chat_replace_url_param_history.
23
+
3
24
  ## 10.26.2
4
25
 
5
26
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.updatePageRovoParams = exports.removePrefix = exports.getRovoParams = exports.getListOfRovoParams = exports.firstCharUpper = exports.firstCharLower = exports.encodeRovoParams = exports.assertOnlySpecificFieldsDefined = exports.addRovoParamsToUrl = exports.addPrefix = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
10
11
  var _constants = require("./constants");
11
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -87,7 +88,15 @@ var getRovoParams = exports.getRovoParams = function getRovoParams(url) {
87
88
 
88
89
  // Update the address bar without reloading the page
89
90
  var updatePageRovoParams = exports.updatePageRovoParams = function updatePageRovoParams(params) {
90
- window.history.pushState({}, '', addRovoParamsToUrl(window.location.pathname, params));
91
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
92
+ _ref$historyMode = _ref.historyMode,
93
+ historyMode = _ref$historyMode === void 0 ? 'push' : _ref$historyMode;
94
+ var updatedUrl = addRovoParamsToUrl(window.location.pathname, params);
95
+ if (historyMode === 'replace' && (0, _fg.fg)('rovo_chat_replace_url_param_history')) {
96
+ window.history.replaceState({}, '', updatedUrl);
97
+ return;
98
+ }
99
+ window.history.pushState({}, '', updatedUrl);
91
100
  };
92
101
 
93
102
  // Add any valid rovoChat params to a URL
@@ -103,31 +112,31 @@ var addRovoParamsToUrl = exports.addRovoParamsToUrl = function addRovoParamsToUr
103
112
  };
104
113
  var encodeRovoParams = exports.encodeRovoParams = function encodeRovoParams(params, encodeAsObject) {
105
114
  if (encodeAsObject) {
106
- return Object.entries(params).reduce(function (acc, _ref) {
107
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
108
- key = _ref2[0],
109
- value = _ref2[1];
115
+ return Object.entries(params).reduce(function (acc, _ref2) {
116
+ var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
117
+ key = _ref3[0],
118
+ value = _ref3[1];
110
119
  acc[addPrefix(key)] = encodeURIComponent(value);
111
120
  return acc;
112
121
  }, {});
113
122
  }
114
- return Object.entries(params).filter(function (_ref3) {
115
- var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
116
- _ = _ref4[0],
117
- value = _ref4[1];
123
+ return Object.entries(params).filter(function (_ref4) {
124
+ var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
125
+ _ = _ref5[0],
126
+ value = _ref5[1];
118
127
  return value !== undefined;
119
- }).map(function (_ref5) {
120
- var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
121
- key = _ref6[0],
122
- value = _ref6[1];
128
+ }).map(function (_ref6) {
129
+ var _ref7 = (0, _slicedToArray2.default)(_ref6, 2),
130
+ key = _ref7[0],
131
+ value = _ref7[1];
123
132
  return "".concat(addPrefix(key), "=").concat(encodeURIComponent(value));
124
133
  }).join('&');
125
134
  };
126
135
  var assertOnlySpecificFieldsDefined = exports.assertOnlySpecificFieldsDefined = function assertOnlySpecificFieldsDefined(params, fields) {
127
- return Object.entries(params).every(function (_ref7) {
128
- var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
129
- key = _ref8[0],
130
- value = _ref8[1];
136
+ return Object.entries(params).every(function (_ref8) {
137
+ var _ref9 = (0, _slicedToArray2.default)(_ref8, 2),
138
+ key = _ref9[0],
139
+ value = _ref9[1];
131
140
  var field = fields.find(function (field) {
132
141
  return field === key;
133
142
  });
@@ -139,9 +148,9 @@ var assertOnlySpecificFieldsDefined = exports.assertOnlySpecificFieldsDefined =
139
148
  });
140
149
  };
141
150
  var getListOfRovoParams = exports.getListOfRovoParams = function getListOfRovoParams() {
142
- var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
143
- _ref9$resourceRouterQ = _ref9.resourceRouterQuery,
144
- resourceRouterQuery = _ref9$resourceRouterQ === void 0 ? false : _ref9$resourceRouterQ;
151
+ var _ref0 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
152
+ _ref0$resourceRouterQ = _ref0.resourceRouterQuery,
153
+ resourceRouterQuery = _ref0$resourceRouterQ === void 0 ? false : _ref0$resourceRouterQ;
145
154
  /*
146
155
  For products using react-resource-router (e.g Atlas) to
147
156
  pass as the value of `query` on the route definition. It ensures that our parameters
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
1
2
  import { ROVO_PARAM_PREFIX, ROVO_VALID_PARAMS } from './constants';
2
3
  export const firstCharUpper = str => str.charAt(0).toUpperCase() + str.slice(1);
3
4
  export const firstCharLower = str => str.charAt(0).toLowerCase() + str.slice(1);
@@ -64,8 +65,15 @@ export const getRovoParams = url => {
64
65
  };
65
66
 
66
67
  // Update the address bar without reloading the page
67
- export const updatePageRovoParams = params => {
68
- window.history.pushState({}, '', addRovoParamsToUrl(window.location.pathname, params));
68
+ export const updatePageRovoParams = (params, {
69
+ historyMode = 'push'
70
+ } = {}) => {
71
+ const updatedUrl = addRovoParamsToUrl(window.location.pathname, params);
72
+ if (historyMode === 'replace' && fg('rovo_chat_replace_url_param_history')) {
73
+ window.history.replaceState({}, '', updatedUrl);
74
+ return;
75
+ }
76
+ window.history.pushState({}, '', updatedUrl);
69
77
  };
70
78
 
71
79
  // Add any valid rovoChat params to a URL
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
6
  import { ROVO_PARAM_PREFIX, ROVO_VALID_PARAMS } from './constants';
6
7
  export var firstCharUpper = function firstCharUpper(str) {
7
8
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -80,7 +81,15 @@ export var getRovoParams = function getRovoParams(url) {
80
81
 
81
82
  // Update the address bar without reloading the page
82
83
  export var updatePageRovoParams = function updatePageRovoParams(params) {
83
- window.history.pushState({}, '', addRovoParamsToUrl(window.location.pathname, params));
84
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
85
+ _ref$historyMode = _ref.historyMode,
86
+ historyMode = _ref$historyMode === void 0 ? 'push' : _ref$historyMode;
87
+ var updatedUrl = addRovoParamsToUrl(window.location.pathname, params);
88
+ if (historyMode === 'replace' && fg('rovo_chat_replace_url_param_history')) {
89
+ window.history.replaceState({}, '', updatedUrl);
90
+ return;
91
+ }
92
+ window.history.pushState({}, '', updatedUrl);
84
93
  };
85
94
 
86
95
  // Add any valid rovoChat params to a URL
@@ -96,31 +105,31 @@ export var addRovoParamsToUrl = function addRovoParamsToUrl(url, params) {
96
105
  };
97
106
  export var encodeRovoParams = function encodeRovoParams(params, encodeAsObject) {
98
107
  if (encodeAsObject) {
99
- return Object.entries(params).reduce(function (acc, _ref) {
100
- var _ref2 = _slicedToArray(_ref, 2),
101
- key = _ref2[0],
102
- value = _ref2[1];
108
+ return Object.entries(params).reduce(function (acc, _ref2) {
109
+ var _ref3 = _slicedToArray(_ref2, 2),
110
+ key = _ref3[0],
111
+ value = _ref3[1];
103
112
  acc[addPrefix(key)] = encodeURIComponent(value);
104
113
  return acc;
105
114
  }, {});
106
115
  }
107
- return Object.entries(params).filter(function (_ref3) {
108
- var _ref4 = _slicedToArray(_ref3, 2),
109
- _ = _ref4[0],
110
- value = _ref4[1];
116
+ return Object.entries(params).filter(function (_ref4) {
117
+ var _ref5 = _slicedToArray(_ref4, 2),
118
+ _ = _ref5[0],
119
+ value = _ref5[1];
111
120
  return value !== undefined;
112
- }).map(function (_ref5) {
113
- var _ref6 = _slicedToArray(_ref5, 2),
114
- key = _ref6[0],
115
- value = _ref6[1];
121
+ }).map(function (_ref6) {
122
+ var _ref7 = _slicedToArray(_ref6, 2),
123
+ key = _ref7[0],
124
+ value = _ref7[1];
116
125
  return "".concat(addPrefix(key), "=").concat(encodeURIComponent(value));
117
126
  }).join('&');
118
127
  };
119
128
  export var assertOnlySpecificFieldsDefined = function assertOnlySpecificFieldsDefined(params, fields) {
120
- return Object.entries(params).every(function (_ref7) {
121
- var _ref8 = _slicedToArray(_ref7, 2),
122
- key = _ref8[0],
123
- value = _ref8[1];
129
+ return Object.entries(params).every(function (_ref8) {
130
+ var _ref9 = _slicedToArray(_ref8, 2),
131
+ key = _ref9[0],
132
+ value = _ref9[1];
124
133
  var field = fields.find(function (field) {
125
134
  return field === key;
126
135
  });
@@ -132,9 +141,9 @@ export var assertOnlySpecificFieldsDefined = function assertOnlySpecificFieldsDe
132
141
  });
133
142
  };
134
143
  export var getListOfRovoParams = function getListOfRovoParams() {
135
- var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
136
- _ref9$resourceRouterQ = _ref9.resourceRouterQuery,
137
- resourceRouterQuery = _ref9$resourceRouterQ === void 0 ? false : _ref9$resourceRouterQ;
144
+ var _ref0 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
145
+ _ref0$resourceRouterQ = _ref0.resourceRouterQuery,
146
+ resourceRouterQuery = _ref0$resourceRouterQ === void 0 ? false : _ref0$resourceRouterQ;
138
147
  /*
139
148
  For products using react-resource-router (e.g Atlas) to
140
149
  pass as the value of `query` on the route definition. It ensures that our parameters
@@ -4,7 +4,9 @@ export declare const firstCharLower: (str: string) => string;
4
4
  export declare const addPrefix: (param: ValidParam) => string;
5
5
  export declare const removePrefix: (param: string) => string;
6
6
  export declare const getRovoParams: (url?: string) => RovoChatParams;
7
- export declare const updatePageRovoParams: (params: RovoChatParams) => void;
7
+ export declare const updatePageRovoParams: (params: RovoChatParams, { historyMode }?: {
8
+ historyMode?: 'push' | 'replace';
9
+ }) => void;
8
10
  export declare const addRovoParamsToUrl: (url: string, params: RovoChatParams) => string;
9
11
  export declare const encodeRovoParams: (params: RovoChatParams, encodeAsObject?: boolean) => string | {
10
12
  [key: string]: string;
@@ -133,6 +133,8 @@ export type ChatNewPayload = PayloadCore<'chat-new', {
133
133
  files?: UploadedFile[];
134
134
  contentContext?: 'staging-area' | 'global';
135
135
  sourceId?: string;
136
+ /** Correlates a Quick Find journey with the Chat activity it launches. */
137
+ rovoJourneyId?: string;
136
138
  minionAlias?: string;
137
139
  skipCreatingSeededConversation?: boolean;
138
140
  selectedSpace?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/rovo-triggers",
3
- "version": "10.26.2",
3
+ "version": "10.28.0",
4
4
  "description": "Provides various trigger events to drive Rovo Chat functionality, such as a publish-subscribe and URL parameter hooks",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
@@ -44,9 +44,10 @@
44
44
  "@atlaskit/primitives": "^22.5.0",
45
45
  "@atlaskit/ssr": "workspace:^",
46
46
  "@atlassian/a11y-jest-testing": "^0.17.0",
47
- "@atlassian/conversation-assistant-service-api": "^17.5.0",
47
+ "@atlassian/conversation-assistant-service-api": "^17.7.0",
48
48
  "@atlassian/feature-flags-test-utils": "^1.3.0",
49
49
  "@atlassian/testing-library": "^0.11.0",
50
+ "@atlassian/workbench": "workspace:*",
50
51
  "@testing-library/react": "^16.3.0",
51
52
  "react": "^18.2.0",
52
53
  "react-dom": "^18.2.0",
@@ -55,6 +56,9 @@
55
56
  "platform-feature-flags": {
56
57
  "rovo-ext_context_bridge": {
57
58
  "type": "boolean"
59
+ },
60
+ "rovo_chat_replace_url_param_history": {
61
+ "type": "boolean"
58
62
  }
59
63
  }
60
64
  }