@atlaskit/profilecard 24.14.1 → 24.16.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 (87) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/__tests__/vr-tests/agent-profilecard.vr.tsx +5 -5
  3. package/__tests__/vr-tests/user-profilecard.vr.tsx +30 -30
  4. package/dist/cjs/client/ProfileCardClient.js +10 -10
  5. package/dist/cjs/client/RovoAgentCardClient.js +172 -56
  6. package/dist/cjs/client/TeamProfileCardClient.js +44 -14
  7. package/dist/cjs/client/UserProfileCardClient.js +2 -9
  8. package/dist/cjs/client/errorUtils.js +83 -5
  9. package/dist/cjs/components/Agent/Actions.js +20 -9
  10. package/dist/cjs/components/Agent/ActionsCompiled.js +18 -8
  11. package/dist/cjs/components/Agent/AgentDeleteConfirmationModal.js +3 -1
  12. package/dist/cjs/components/Agent/AgentProfileCard.js +24 -14
  13. package/dist/cjs/components/Agent/AgentProfileCardCompiled.js +23 -8
  14. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +8 -5
  15. package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +6 -2
  16. package/dist/cjs/components/Agent/hooks/useAgentActions.js +61 -30
  17. package/dist/cjs/components/Team/TeamForbiddenErrorState.js +21 -6
  18. package/dist/cjs/components/Team/TeamLoadingState.js +21 -6
  19. package/dist/cjs/components/Team/TeamProfileCard.js +155 -60
  20. package/dist/cjs/components/Team/TeamProfileCardTrigger.js +104 -33
  21. package/dist/cjs/components/common/ProfileCardTrigger.js +3 -1
  22. package/dist/cjs/components/team-profile-card/main.js +18 -9
  23. package/dist/cjs/components/team-profile-card/team-connections/main.js +36 -17
  24. package/dist/cjs/util/analytics.js +55 -0
  25. package/dist/es2019/client/ProfileCardClient.js +10 -10
  26. package/dist/es2019/client/RovoAgentCardClient.js +186 -58
  27. package/dist/es2019/client/TeamProfileCardClient.js +49 -16
  28. package/dist/es2019/client/UserProfileCardClient.js +3 -10
  29. package/dist/es2019/client/errorUtils.js +84 -3
  30. package/dist/es2019/components/Agent/Actions.js +21 -9
  31. package/dist/es2019/components/Agent/ActionsCompiled.js +19 -8
  32. package/dist/es2019/components/Agent/AgentDeleteConfirmationModal.js +3 -1
  33. package/dist/es2019/components/Agent/AgentProfileCard.js +24 -13
  34. package/dist/es2019/components/Agent/AgentProfileCardCompiled.js +23 -9
  35. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +9 -5
  36. package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +7 -2
  37. package/dist/es2019/components/Agent/hooks/useAgentActions.js +62 -30
  38. package/dist/es2019/components/Team/TeamForbiddenErrorState.js +17 -6
  39. package/dist/es2019/components/Team/TeamLoadingState.js +17 -6
  40. package/dist/es2019/components/Team/TeamProfileCard.js +144 -54
  41. package/dist/es2019/components/Team/TeamProfileCardTrigger.js +74 -10
  42. package/dist/es2019/components/common/ProfileCardTrigger.js +3 -1
  43. package/dist/es2019/components/team-profile-card/main.js +19 -9
  44. package/dist/es2019/components/team-profile-card/team-connections/main.js +38 -17
  45. package/dist/es2019/util/analytics.js +55 -0
  46. package/dist/esm/client/ProfileCardClient.js +10 -10
  47. package/dist/esm/client/RovoAgentCardClient.js +174 -58
  48. package/dist/esm/client/TeamProfileCardClient.js +46 -16
  49. package/dist/esm/client/UserProfileCardClient.js +3 -10
  50. package/dist/esm/client/errorUtils.js +82 -4
  51. package/dist/esm/components/Agent/Actions.js +20 -9
  52. package/dist/esm/components/Agent/ActionsCompiled.js +18 -8
  53. package/dist/esm/components/Agent/AgentDeleteConfirmationModal.js +3 -1
  54. package/dist/esm/components/Agent/AgentProfileCard.js +25 -13
  55. package/dist/esm/components/Agent/AgentProfileCardCompiled.js +24 -9
  56. package/dist/esm/components/Agent/AgentProfileCardResourced.js +8 -5
  57. package/dist/esm/components/Agent/AgentProfileCardTrigger.js +6 -2
  58. package/dist/esm/components/Agent/hooks/useAgentActions.js +61 -30
  59. package/dist/esm/components/Team/TeamForbiddenErrorState.js +22 -7
  60. package/dist/esm/components/Team/TeamLoadingState.js +22 -7
  61. package/dist/esm/components/Team/TeamProfileCard.js +156 -61
  62. package/dist/esm/components/Team/TeamProfileCardTrigger.js +105 -34
  63. package/dist/esm/components/common/ProfileCardTrigger.js +3 -1
  64. package/dist/esm/components/team-profile-card/main.js +18 -9
  65. package/dist/esm/components/team-profile-card/team-connections/main.js +36 -17
  66. package/dist/esm/util/analytics.js +55 -0
  67. package/dist/types/client/ProfileCardClient.d.ts +5 -5
  68. package/dist/types/client/RovoAgentCardClient.d.ts +5 -4
  69. package/dist/types/client/TeamProfileCardClient.d.ts +2 -1
  70. package/dist/types/client/errorUtils.d.ts +2 -1
  71. package/dist/types/client/types.d.ts +14 -2
  72. package/dist/types/components/Team/TeamForbiddenErrorState.d.ts +2 -1
  73. package/dist/types/components/Team/TeamLoadingState.d.ts +2 -1
  74. package/dist/types/components/Team/TeamProfileCardTrigger.d.ts +7 -2
  75. package/dist/types/types.d.ts +2 -0
  76. package/dist/types/util/analytics.d.ts +46 -2
  77. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +5 -5
  78. package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +5 -4
  79. package/dist/types-ts4.5/client/TeamProfileCardClient.d.ts +2 -1
  80. package/dist/types-ts4.5/client/errorUtils.d.ts +2 -1
  81. package/dist/types-ts4.5/client/types.d.ts +14 -2
  82. package/dist/types-ts4.5/components/Team/TeamForbiddenErrorState.d.ts +2 -1
  83. package/dist/types-ts4.5/components/Team/TeamLoadingState.d.ts +2 -1
  84. package/dist/types-ts4.5/components/Team/TeamProfileCardTrigger.d.ts +7 -2
  85. package/dist/types-ts4.5/types.d.ts +2 -0
  86. package/dist/types-ts4.5/util/analytics.d.ts +46 -2
  87. package/package.json +8 -8
@@ -62,6 +62,11 @@ export const getActionSubject = type => {
62
62
  return 'user';
63
63
  }
64
64
  };
65
+
66
+ /**
67
+ * @private
68
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
69
+ */
65
70
  export const cardTriggered = (type, method, teamId) => {
66
71
  return createEvent('ui', 'triggered', getActionSubject(type), undefined, {
67
72
  method,
@@ -70,13 +75,63 @@ export const cardTriggered = (type, method, teamId) => {
70
75
  } : {})
71
76
  });
72
77
  };
78
+
79
+ /**
80
+ * @private
81
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
82
+ */
73
83
  export const teamRequestAnalytics = (action, attributes) => createEvent('operational', action, TEAM_SUBJECT, 'request', attributes);
84
+
85
+ /**
86
+ * @private
87
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
88
+ */
74
89
  export const userRequestAnalytics = (action, attributes) => createEvent('operational', action, USER_SUBJECT, 'request', attributes);
90
+
91
+ /**
92
+ * @private
93
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
94
+ */
75
95
  export const profileCardRendered = (type, actionSubjectId, attributes) => createEvent('ui', 'rendered', getActionSubject(type), actionSubjectId, attributes);
96
+
97
+ /**
98
+ * @private
99
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
100
+ */
76
101
  export const actionClicked = (type, attributes) => createEvent('ui', 'clicked', getActionSubject(type), 'action', attributes);
102
+
103
+ /**
104
+ * @private
105
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
106
+ */
77
107
  export const reportingLinesClicked = attributes => createEvent('ui', 'clicked', USER_SUBJECT, 'reportingLines', attributes);
108
+
109
+ /**
110
+ * @private
111
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
112
+ */
78
113
  export const moreActionsClicked = (type, attributes) => createEvent('ui', 'clicked', getActionSubject(type), 'moreActions', attributes);
114
+
115
+ /**
116
+ * @private
117
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
118
+ */
79
119
  export const teamAvatarClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'avatar', attributes);
120
+
121
+ /**
122
+ * @private
123
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
124
+ */
80
125
  export const moreMembersClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'moreMembers', attributes);
126
+
127
+ /**
128
+ * @private
129
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
130
+ */
81
131
  export const errorRetryClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'errorRetry', attributes);
132
+
133
+ /**
134
+ * @private
135
+ * @deprecated Analytics events should be fired using the `@atlaskit/teams-app-internal-analytics` package.
136
+ */
82
137
  export const agentRequestAnalytics = (action, actionSubjectId, attributes) => createEvent('operational', action, AGENT_SUBJECT, actionSubjectId || 'request', attributes);
@@ -42,8 +42,8 @@ var ProfileCardClient = /*#__PURE__*/function () {
42
42
  }
43
43
  }, {
44
44
  key: "getTeamProfile",
45
- value: function getTeamProfile(teamId, orgId, analytics) {
46
- return this.teamClient.getProfile(teamId, orgId, analytics);
45
+ value: function getTeamProfile(teamId, orgId, analytics, analyticsNext) {
46
+ return this.teamClient.getProfile(teamId, orgId, analytics, analyticsNext);
47
47
  }
48
48
  }, {
49
49
  key: "getReportingLines",
@@ -147,27 +147,27 @@ var ProfileCardClient = /*#__PURE__*/function () {
147
147
  }()
148
148
  }, {
149
149
  key: "getRovoAgentProfile",
150
- value: function getRovoAgentProfile(id, analytics) {
150
+ value: function getRovoAgentProfile(id, analytics, analyticsNext) {
151
151
  var _this$rovoAgentClient2;
152
- return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics);
152
+ return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics, analyticsNext);
153
153
  }
154
154
  }, {
155
155
  key: "getRovoAgentPermissions",
156
- value: function getRovoAgentPermissions(id, fireAnalytics) {
156
+ value: function getRovoAgentPermissions(id, fireAnalytics, analyticsNext) {
157
157
  var _this$rovoAgentClient3;
158
- return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.getPermissions(id, fireAnalytics);
158
+ return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.getPermissions(id, fireAnalytics, analyticsNext);
159
159
  }
160
160
  }, {
161
161
  key: "deleteAgent",
162
- value: function deleteAgent(id, analytics) {
162
+ value: function deleteAgent(id, analytics, analyticsNext) {
163
163
  var _this$rovoAgentClient4;
164
- return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.deleteAgent(id, analytics);
164
+ return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.deleteAgent(id, analytics, analyticsNext);
165
165
  }
166
166
  }, {
167
167
  key: "setFavouriteAgent",
168
- value: function setFavouriteAgent(id, isFavourite, analytics) {
168
+ value: function setFavouriteAgent(id, isFavourite, analytics, analyticsNext) {
169
169
  var _this$rovoAgentClient5;
170
- return (_this$rovoAgentClient5 = this.rovoAgentClient) === null || _this$rovoAgentClient5 === void 0 ? void 0 : _this$rovoAgentClient5.setFavouriteAgent(id, isFavourite, analytics);
170
+ return (_this$rovoAgentClient5 = this.rovoAgentClient) === null || _this$rovoAgentClient5 === void 0 ? void 0 : _this$rovoAgentClient5.setFavouriteAgent(id, isFavourite, analytics, analyticsNext);
171
171
  }
172
172
  }]);
173
173
  }();
@@ -11,10 +11,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
11
11
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
- import { agentRequestAnalytics } from '../util/analytics';
14
+ import { agentRequestAnalytics, PACKAGE_META_DATA } from '../util/analytics';
15
15
  import { getPageTime } from '../util/performance';
16
16
  import CachingClient from './CachingClient';
17
- import { getErrorAttributes } from './errorUtils';
17
+ import { DEPRECATED_getErrorAttributes, getErrorAttributes } from './errorUtils';
18
18
  var createHeaders = function createHeaders(product, cloudId, isBodyJson) {
19
19
  var headers = new Headers({
20
20
  'X-Product': product,
@@ -66,7 +66,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
66
66
  }
67
67
  }, {
68
68
  key: "getProfile",
69
- value: function getProfile(id, analytics) {
69
+ value: function getProfile(id, analytics, analyticsNext) {
70
70
  var _this2 = this;
71
71
  if (!id.value) {
72
72
  return Promise.reject(new Error('Id is missing'));
@@ -80,27 +80,56 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
80
80
  }
81
81
  return new Promise(function (resolve, reject) {
82
82
  var startTime = getPageTime();
83
- if (analytics) {
84
- analytics(agentRequestAnalytics('triggered'));
83
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
84
+ if (analyticsNext) {
85
+ analyticsNext('operational.rovoAgentProfilecard.triggered.request', _objectSpread({
86
+ firedAt: Math.round(getPageTime())
87
+ }, PACKAGE_META_DATA));
88
+ }
89
+ } else {
90
+ if (analytics) {
91
+ analytics(agentRequestAnalytics('triggered'));
92
+ }
85
93
  }
86
94
  _this2.makeRequest(id, _this2.options.cloudId || '').then(function (data) {
87
95
  if (_this2.cache) {
88
96
  _this2.setCachedProfile(id.value, data);
89
97
  }
90
- if (analytics) {
91
- analytics(agentRequestAnalytics('succeeded', 'request', {
92
- duration: getPageTime() - startTime,
93
- gateway: true
94
- }));
98
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
99
+ if (analyticsNext) {
100
+ analyticsNext('operational.rovoAgentProfilecard.succeeded.request', _objectSpread({
101
+ duration: getPageTime() - startTime,
102
+ gateway: true,
103
+ firedAt: Math.round(getPageTime())
104
+ }, PACKAGE_META_DATA));
105
+ }
106
+ } else {
107
+ if (analytics) {
108
+ analytics(agentRequestAnalytics('succeeded', 'request', {
109
+ duration: getPageTime() - startTime,
110
+ gateway: true
111
+ }));
112
+ }
95
113
  }
96
114
  resolve(data);
97
115
  }).catch(function (error) {
98
- if (analytics) {
99
- analytics(agentRequestAnalytics('failed', 'request', _objectSpread(_objectSpread({
100
- duration: getPageTime() - startTime
101
- }, getErrorAttributes(error)), {}, {
102
- gateway: true
103
- })));
116
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
117
+ if (analyticsNext) {
118
+ analyticsNext('operational.rovoAgentProfilecard.failed.request', _objectSpread(_objectSpread({
119
+ duration: getPageTime() - startTime
120
+ }, getErrorAttributes(error)), {}, {
121
+ gateway: true,
122
+ firedAt: Math.round(getPageTime())
123
+ }, PACKAGE_META_DATA));
124
+ }
125
+ } else {
126
+ if (analytics) {
127
+ analytics(agentRequestAnalytics('failed', 'request', _objectSpread(_objectSpread({
128
+ duration: getPageTime() - startTime
129
+ }, DEPRECATED_getErrorAttributes(error)), {}, {
130
+ gateway: true
131
+ })));
132
+ }
104
133
  }
105
134
  reject(error);
106
135
  });
@@ -108,7 +137,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
108
137
  }
109
138
  }, {
110
139
  key: "deleteAgent",
111
- value: function deleteAgent(agentId, analytics) {
140
+ value: function deleteAgent(agentId, analytics, analyticsNext) {
112
141
  var _this3 = this;
113
142
  if (!this.options.cloudId) {
114
143
  return Promise.reject(new Error('cloudId is missing'));
@@ -116,8 +145,16 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
116
145
  return new Promise(function (resolve, reject) {
117
146
  var startTime = getPageTime();
118
147
  var product = _this3.options.productIdentifier || 'rovo';
119
- if (analytics) {
120
- analytics(agentRequestAnalytics('triggered'));
148
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
149
+ if (analyticsNext) {
150
+ analyticsNext('operational.rovoAgentProfilecard.triggered.request', _objectSpread({
151
+ firedAt: Math.round(getPageTime())
152
+ }, PACKAGE_META_DATA));
153
+ }
154
+ } else {
155
+ if (analytics) {
156
+ analytics(agentRequestAnalytics('triggered'));
157
+ }
121
158
  }
122
159
  var headers = createHeaders(product, _this3.options.cloudId);
123
160
  fetch(new Request("".concat(_this3.basePath(), "/").concat(agentId), {
@@ -126,20 +163,41 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
126
163
  mode: 'cors',
127
164
  headers: headers
128
165
  })).then(function () {
129
- if (analytics) {
130
- analytics(agentRequestAnalytics('succeeded', 'deleteAgent', {
131
- duration: getPageTime() - startTime,
132
- gateway: true
133
- }));
166
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
167
+ if (analyticsNext) {
168
+ analyticsNext('operational.rovoAgentProfilecard.succeeded.deleteAgent', _objectSpread({
169
+ duration: getPageTime() - startTime,
170
+ gateway: true,
171
+ firedAt: Math.round(getPageTime())
172
+ }, PACKAGE_META_DATA));
173
+ }
174
+ } else {
175
+ if (analytics) {
176
+ analytics(agentRequestAnalytics('succeeded', 'deleteAgent', {
177
+ duration: getPageTime() - startTime,
178
+ gateway: true
179
+ }));
180
+ }
134
181
  }
135
182
  resolve();
136
183
  }).catch(function (error) {
137
- if (analytics) {
138
- analytics(agentRequestAnalytics('failed', 'deleteAgent', _objectSpread(_objectSpread({
139
- duration: getPageTime() - startTime
140
- }, getErrorAttributes(error)), {}, {
141
- gateway: true
142
- })));
184
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
185
+ if (analyticsNext) {
186
+ analyticsNext('operational.rovoAgentProfilecard.failed.deleteAgent', _objectSpread(_objectSpread({
187
+ duration: getPageTime() - startTime
188
+ }, getErrorAttributes(error)), {}, {
189
+ gateway: true,
190
+ firedAt: Math.round(getPageTime())
191
+ }, PACKAGE_META_DATA));
192
+ }
193
+ } else {
194
+ if (analytics) {
195
+ analytics(agentRequestAnalytics('failed', 'deleteAgent', _objectSpread(_objectSpread({
196
+ duration: getPageTime() - startTime
197
+ }, DEPRECATED_getErrorAttributes(error)), {}, {
198
+ gateway: true
199
+ })));
200
+ }
143
201
  }
144
202
  reject(error);
145
203
  });
@@ -147,7 +205,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
147
205
  }
148
206
  }, {
149
207
  key: "setFavouriteAgent",
150
- value: function setFavouriteAgent(agentId, isFavourite, analytics) {
208
+ value: function setFavouriteAgent(agentId, isFavourite, analytics, analyticsNext) {
151
209
  var _this4 = this;
152
210
  if (!this.options.cloudId) {
153
211
  return Promise.reject(new Error('cloudId is missing'));
@@ -162,8 +220,16 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
162
220
  product = _this4.options.productIdentifier || 'rovo';
163
221
  actionSubjectId = isFavourite ? 'favourite' : 'unfavourite';
164
222
  requestMethod = isFavourite ? 'POST' : 'DELETE';
165
- if (analytics) {
166
- analytics(agentRequestAnalytics('triggered', 'actionSubjectId'));
223
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
224
+ if (analyticsNext) {
225
+ analyticsNext("operational.rovoAgentProfilecard.triggered.".concat(actionSubjectId), _objectSpread({
226
+ firedAt: Math.round(getPageTime())
227
+ }, PACKAGE_META_DATA));
228
+ }
229
+ } else {
230
+ if (analytics) {
231
+ analytics(agentRequestAnalytics('triggered', 'actionSubjectId'));
232
+ }
167
233
  }
168
234
  headers = createHeaders(product, _this4.options.cloudId);
169
235
  _context.next = 8;
@@ -173,20 +239,41 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
173
239
  mode: 'cors',
174
240
  headers: headers
175
241
  })).then(function () {
176
- if (analytics) {
177
- analytics(agentRequestAnalytics('succeeded', actionSubjectId, {
178
- duration: getPageTime() - startTime,
179
- gateway: true
180
- }));
242
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
243
+ if (analyticsNext) {
244
+ analyticsNext("operational.rovoAgentProfilecard.succeeded.".concat(actionSubjectId), _objectSpread({
245
+ duration: getPageTime() - startTime,
246
+ gateway: true,
247
+ firedAt: Math.round(getPageTime())
248
+ }, PACKAGE_META_DATA));
249
+ }
250
+ } else {
251
+ if (analytics) {
252
+ analytics(agentRequestAnalytics('succeeded', actionSubjectId, {
253
+ duration: getPageTime() - startTime,
254
+ gateway: true
255
+ }));
256
+ }
181
257
  }
182
258
  resolve();
183
259
  }).catch(function (error) {
184
- if (analytics) {
185
- analytics(agentRequestAnalytics('failed', actionSubjectId, _objectSpread(_objectSpread({
186
- duration: getPageTime() - startTime
187
- }, getErrorAttributes(error)), {}, {
188
- gateway: true
189
- })));
260
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
261
+ if (analyticsNext) {
262
+ analyticsNext("operational.rovoAgentProfilecard.failed.".concat(actionSubjectId), _objectSpread(_objectSpread({
263
+ duration: getPageTime() - startTime
264
+ }, getErrorAttributes(error)), {}, {
265
+ gateway: true,
266
+ firedAt: Math.round(getPageTime())
267
+ }, PACKAGE_META_DATA));
268
+ }
269
+ } else {
270
+ if (analytics) {
271
+ analytics(agentRequestAnalytics('failed', actionSubjectId, _objectSpread(_objectSpread({
272
+ duration: getPageTime() - startTime
273
+ }, DEPRECATED_getErrorAttributes(error)), {}, {
274
+ gateway: true
275
+ })));
276
+ }
190
277
  }
191
278
  reject(error);
192
279
  });
@@ -203,7 +290,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
203
290
  }
204
291
  }, {
205
292
  key: "getPermissions",
206
- value: function getPermissions(id, fireAnalytics) {
293
+ value: function getPermissions(id, fireAnalytics, fireAnalyticsNext) {
207
294
  var _this5 = this;
208
295
  if (!this.options.cloudId) {
209
296
  return Promise.reject(new Error('cloudId is missing'));
@@ -211,8 +298,16 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
211
298
  return new Promise(function (resolve, reject) {
212
299
  var startTime = getPageTime();
213
300
  var product = _this5.options.productIdentifier || 'rovo';
214
- if (fireAnalytics) {
215
- fireAnalytics(agentRequestAnalytics('triggered'));
301
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
302
+ if (fireAnalyticsNext) {
303
+ fireAnalyticsNext('operational.rovoAgentProfilecard.triggered.request', _objectSpread({
304
+ firedAt: Math.round(getPageTime())
305
+ }, PACKAGE_META_DATA));
306
+ }
307
+ } else {
308
+ if (fireAnalytics) {
309
+ fireAnalytics(agentRequestAnalytics('triggered'));
310
+ }
216
311
  }
217
312
  var headers = createHeaders(product, _this5.options.cloudId, true);
218
313
  fetch(new Request("/gateway/api/assist/api/rovo/v2/permissions/agents/".concat(id), {
@@ -226,20 +321,41 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
226
321
  })).then(function (response) {
227
322
  return response.json();
228
323
  }).then(function (data) {
229
- if (fireAnalytics) {
230
- fireAnalytics(agentRequestAnalytics('succeeded', 'getAgentPermissions', {
231
- duration: getPageTime() - startTime,
232
- gateway: true
233
- }));
324
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
325
+ if (fireAnalyticsNext) {
326
+ fireAnalyticsNext('operational.rovoAgentProfilecard.succeeded.getAgentPermissions', _objectSpread({
327
+ duration: getPageTime() - startTime,
328
+ gateway: true,
329
+ firedAt: Math.round(getPageTime())
330
+ }, PACKAGE_META_DATA));
331
+ }
332
+ } else {
333
+ if (fireAnalytics) {
334
+ fireAnalytics(agentRequestAnalytics('succeeded', 'getAgentPermissions', {
335
+ duration: getPageTime() - startTime,
336
+ gateway: true
337
+ }));
338
+ }
234
339
  }
235
340
  resolve(data);
236
341
  }).catch(function (error) {
237
- if (fireAnalytics) {
238
- fireAnalytics(agentRequestAnalytics('failed', 'getAgentPermissions', _objectSpread(_objectSpread({
239
- duration: getPageTime() - startTime
240
- }, getErrorAttributes(error)), {}, {
241
- gateway: true
242
- })));
342
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
343
+ if (fireAnalyticsNext) {
344
+ fireAnalyticsNext('operational.rovoAgentProfilecard.failed.getAgentPermissions', _objectSpread(_objectSpread({
345
+ duration: getPageTime() - startTime
346
+ }, getErrorAttributes(error)), {}, {
347
+ gateway: true,
348
+ firedAt: Math.round(getPageTime())
349
+ }, PACKAGE_META_DATA));
350
+ }
351
+ } else {
352
+ if (fireAnalytics) {
353
+ fireAnalytics(agentRequestAnalytics('failed', 'getAgentPermissions', _objectSpread(_objectSpread({
354
+ duration: getPageTime() - startTime
355
+ }, DEPRECATED_getErrorAttributes(error)), {}, {
356
+ gateway: true
357
+ })));
358
+ }
243
359
  }
244
360
  reject(error);
245
361
  });
@@ -8,10 +8,11 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
8
8
  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; }
9
9
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
- import { teamRequestAnalytics } from '../util/analytics';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { PACKAGE_META_DATA, teamRequestAnalytics } from '../util/analytics';
12
13
  import { getPageTime } from '../util/performance';
13
14
  import CachingClient from './CachingClient';
14
- import { getErrorAttributes } from './errorUtils';
15
+ import { DEPRECATED_getErrorAttributes, getErrorAttributes } from './errorUtils';
15
16
  import { getTeamFromAGG } from './getTeamFromAGG';
16
17
  var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
17
18
  function TeamProfileCardClient(options) {
@@ -32,7 +33,7 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
32
33
  }
33
34
  }, {
34
35
  key: "getProfile",
35
- value: function getProfile(teamId, orgId, analytics) {
36
+ value: function getProfile(teamId, orgId, analytics, analyticsNext) {
36
37
  var _this2 = this;
37
38
  if (!teamId) {
38
39
  return Promise.reject(new Error('teamId is missing'));
@@ -43,27 +44,56 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
43
44
  }
44
45
  return new Promise(function (resolve, reject) {
45
46
  var startTime = getPageTime();
46
- if (analytics) {
47
- analytics(teamRequestAnalytics('triggered'));
47
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
48
+ if (analyticsNext) {
49
+ analyticsNext('operational.teamProfileCard.triggered.request', _objectSpread({
50
+ firedAt: Math.round(getPageTime())
51
+ }, PACKAGE_META_DATA));
52
+ }
53
+ } else {
54
+ if (analytics) {
55
+ analytics(teamRequestAnalytics('triggered'));
56
+ }
48
57
  }
49
58
  _this2.makeRequest(teamId, orgId).then(function (data) {
50
59
  if (_this2.cache) {
51
60
  _this2.setCachedProfile(teamId, data);
52
61
  }
53
- if (analytics) {
54
- analytics(teamRequestAnalytics('succeeded', {
55
- duration: getPageTime() - startTime,
56
- gateway: true
57
- }));
62
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
63
+ if (analyticsNext) {
64
+ analyticsNext('operational.teamProfileCard.succeeded.request', _objectSpread({
65
+ duration: getPageTime() - startTime,
66
+ gateway: true,
67
+ firedAt: Math.round(getPageTime())
68
+ }, PACKAGE_META_DATA));
69
+ }
70
+ } else {
71
+ if (analytics) {
72
+ analytics(teamRequestAnalytics('succeeded', {
73
+ duration: getPageTime() - startTime,
74
+ gateway: true
75
+ }));
76
+ }
58
77
  }
59
78
  resolve(data);
60
79
  }).catch(function (error) {
61
- if (analytics) {
62
- analytics(teamRequestAnalytics('failed', _objectSpread(_objectSpread({
63
- duration: getPageTime() - startTime
64
- }, getErrorAttributes(error)), {}, {
65
- gateway: true
66
- })));
80
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
81
+ if (analyticsNext) {
82
+ analyticsNext('operational.teamProfileCard.failed.request', _objectSpread(_objectSpread({
83
+ duration: getPageTime() - startTime
84
+ }, getErrorAttributes(error)), {}, {
85
+ gateway: true,
86
+ firedAt: Math.round(getPageTime())
87
+ }, PACKAGE_META_DATA));
88
+ }
89
+ } else {
90
+ if (analytics) {
91
+ analytics(teamRequestAnalytics('failed', _objectSpread(_objectSpread({
92
+ duration: getPageTime() - startTime
93
+ }, DEPRECATED_getErrorAttributes(error)), {}, {
94
+ gateway: true
95
+ })));
96
+ }
67
97
  }
68
98
  reject(error);
69
99
  });
@@ -19,7 +19,7 @@ import { PACKAGE_META_DATA, userRequestAnalytics } from '../util/analytics';
19
19
  import { localTime } from '../util/date';
20
20
  import { getPageTime } from '../util/performance';
21
21
  import CachingClient from './CachingClient';
22
- import { getErrorAttributes } from './errorUtils';
22
+ import { DEPRECATED_getErrorAttributes, getErrorAttributes } from './errorUtils';
23
23
  import { AGGQuery } from './graphqlUtils';
24
24
 
25
25
  /**
@@ -192,16 +192,9 @@ var UserProfileCardClient = /*#__PURE__*/function (_CachingClient) {
192
192
  }).catch(function (error) {
193
193
  if (fg('ptc-enable-profile-card-analytics-refactor')) {
194
194
  if (analyticsNext) {
195
- var errorAttributes = getErrorAttributes(error);
196
195
  analyticsNext('operational.profilecard.failed.request', _objectSpread(_objectSpread({
197
196
  duration: getPageTime() - startTime
198
- }, errorAttributes), {}, {
199
- traceId: errorAttributes.traceId || null,
200
- errorCategory: errorAttributes.errorCategory || null,
201
- errorType: errorAttributes.errorType || null,
202
- errorPath: errorAttributes.errorPath || null,
203
- errorNumber: errorAttributes.errorNumber || null,
204
- errorStatusCode: errorAttributes.errorStatusCode || null,
197
+ }, getErrorAttributes(error)), {}, {
205
198
  firedAt: Math.round(getPageTime())
206
199
  }, PACKAGE_META_DATA));
207
200
  }
@@ -209,7 +202,7 @@ var UserProfileCardClient = /*#__PURE__*/function (_CachingClient) {
209
202
  if (analytics) {
210
203
  analytics(userRequestAnalytics('failed', _objectSpread({
211
204
  duration: getPageTime() - startTime
212
- }, getErrorAttributes(error))));
205
+ }, DEPRECATED_getErrorAttributes(error))));
213
206
  }
214
207
  }
215
208
  reject(error);