@atlaskit/profilecard 24.13.6 → 24.14.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 (142) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/__tests__/vr-tests/__snapshots__/agent-profilecard/agent-profile-card-example--default.png +0 -0
  3. package/__tests__/vr-tests/__snapshots__/user-profilecard/alternate-actions--default.png +0 -0
  4. package/__tests__/vr-tests/__snapshots__/user-profilecard/best-case-profile--default.png +0 -0
  5. package/__tests__/vr-tests/__snapshots__/user-profilecard/bot-case-profile--default.png +0 -0
  6. package/__tests__/vr-tests/__snapshots__/user-profilecard/error-state--default.png +0 -0
  7. package/__tests__/vr-tests/__snapshots__/user-profilecard/error-state-not-found--default.png +0 -0
  8. package/__tests__/vr-tests/__snapshots__/user-profilecard/worst-case-profile--default.png +0 -0
  9. package/__tests__/vr-tests/agent-profilecard.vr.tsx +5 -0
  10. package/__tests__/vr-tests/user-profilecard.vr.tsx +17 -0
  11. package/afm-cc/tsconfig.json +6 -0
  12. package/afm-dev-agents/tsconfig.json +6 -0
  13. package/afm-jira/tsconfig.json +6 -0
  14. package/afm-passionfruit/tsconfig.json +6 -0
  15. package/afm-post-office/tsconfig.json +6 -0
  16. package/afm-rovo-extension/tsconfig.json +6 -0
  17. package/afm-townsquare/tsconfig.json +6 -0
  18. package/dist/cjs/client/ProfileCardClient.js +2 -2
  19. package/dist/cjs/client/UserProfileCardClient.js +45 -11
  20. package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
  21. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  22. package/dist/cjs/components/Agent/AgentProfileCard.js +3 -0
  23. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +2 -1
  24. package/dist/cjs/components/Error/ErrorMessage.js +18 -7
  25. package/dist/cjs/components/User/OverflowProfileCardButtons.js +22 -7
  26. package/dist/cjs/components/User/ProfileCard.js +80 -28
  27. package/dist/cjs/components/User/ProfileCardDetails.js +3 -2
  28. package/dist/cjs/components/User/ProfileCardResourced.js +40 -16
  29. package/dist/cjs/components/User/ProfileCardTrigger.js +53 -13
  30. package/dist/cjs/components/User/ReportingLinesDetails.js +37 -12
  31. package/dist/cjs/components/User/UserLoadingState.js +15 -3
  32. package/dist/cjs/components/common/LoadingState.js +17 -3
  33. package/dist/cjs/components/common/ProfileCardTrigger.js +29 -7
  34. package/dist/cjs/components/common/ProfileCardWrapper.js +4 -2
  35. package/dist/cjs/components/team-profile-card/main.js +1 -1
  36. package/dist/cjs/components/team-profile-card/team-connections/main.js +3 -19
  37. package/dist/cjs/components/team-profile-card/team-containers-skeleton/index.js +1 -1
  38. package/dist/cjs/components/team-profile-card/team-containers-skeleton/linked-container-card-skeleton/index.js +1 -1
  39. package/dist/cjs/mocks/mock-profile-client.js +10 -0
  40. package/dist/cjs/mocks/profile-data.js +2 -2
  41. package/dist/cjs/mocks/reporting-lines-data.js +4 -3
  42. package/dist/cjs/styled/Card.js +1 -1
  43. package/dist/cjs/styled/CoverImage.js +1 -1
  44. package/dist/cjs/styled/Error.js +1 -1
  45. package/dist/cjs/styled/ReportingLines.js +1 -1
  46. package/dist/cjs/styled/TeamCard.js +1 -1
  47. package/dist/cjs/styled/TeamTrigger.js +1 -1
  48. package/dist/cjs/styled/UserTrigger.js +1 -1
  49. package/dist/cjs/util/analytics.js +7 -3
  50. package/dist/es2019/client/ProfileCardClient.js +2 -2
  51. package/dist/es2019/client/UserProfileCardClient.js +50 -13
  52. package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
  53. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  54. package/dist/es2019/components/Agent/AgentProfileCard.js +3 -0
  55. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +2 -1
  56. package/dist/es2019/components/Error/ErrorMessage.js +17 -6
  57. package/dist/es2019/components/User/OverflowProfileCardButtons.js +18 -7
  58. package/dist/es2019/components/User/ProfileCard.js +72 -25
  59. package/dist/es2019/components/User/ProfileCardDetails.js +3 -2
  60. package/dist/es2019/components/User/ProfileCardResourced.js +25 -4
  61. package/dist/es2019/components/User/ProfileCardTrigger.js +55 -14
  62. package/dist/es2019/components/User/ReportingLinesDetails.js +31 -10
  63. package/dist/es2019/components/User/UserLoadingState.js +14 -4
  64. package/dist/es2019/components/common/LoadingState.js +16 -4
  65. package/dist/es2019/components/common/ProfileCardTrigger.js +26 -7
  66. package/dist/es2019/components/common/ProfileCardWrapper.js +4 -2
  67. package/dist/es2019/components/team-profile-card/main.js +1 -1
  68. package/dist/es2019/components/team-profile-card/team-connections/main.js +3 -18
  69. package/dist/es2019/components/team-profile-card/team-containers-skeleton/index.js +1 -1
  70. package/dist/es2019/components/team-profile-card/team-containers-skeleton/linked-container-card-skeleton/index.js +1 -1
  71. package/dist/es2019/mocks/mock-profile-client.js +6 -0
  72. package/dist/es2019/mocks/profile-data.js +1 -1
  73. package/dist/es2019/mocks/reporting-lines-data.js +2 -2
  74. package/dist/es2019/styled/Card.js +1 -1
  75. package/dist/es2019/styled/CoverImage.js +1 -1
  76. package/dist/es2019/styled/Error.js +1 -1
  77. package/dist/es2019/styled/ReportingLines.js +1 -1
  78. package/dist/es2019/styled/TeamCard.js +1 -1
  79. package/dist/es2019/styled/TeamTrigger.js +1 -1
  80. package/dist/es2019/styled/UserTrigger.js +1 -1
  81. package/dist/es2019/util/analytics.js +6 -2
  82. package/dist/esm/client/ProfileCardClient.js +2 -2
  83. package/dist/esm/client/UserProfileCardClient.js +46 -12
  84. package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
  85. package/dist/esm/client/getTeamFromAGG.js +1 -1
  86. package/dist/esm/components/Agent/AgentProfileCard.js +3 -0
  87. package/dist/esm/components/Agent/AgentProfileCardResourced.js +2 -1
  88. package/dist/esm/components/Error/ErrorMessage.js +19 -6
  89. package/dist/esm/components/User/OverflowProfileCardButtons.js +23 -8
  90. package/dist/esm/components/User/ProfileCard.js +80 -28
  91. package/dist/esm/components/User/ProfileCardDetails.js +3 -2
  92. package/dist/esm/components/User/ProfileCardResourced.js +40 -16
  93. package/dist/esm/components/User/ProfileCardTrigger.js +54 -14
  94. package/dist/esm/components/User/ReportingLinesDetails.js +38 -12
  95. package/dist/esm/components/User/UserLoadingState.js +16 -4
  96. package/dist/esm/components/common/LoadingState.js +18 -4
  97. package/dist/esm/components/common/ProfileCardTrigger.js +30 -8
  98. package/dist/esm/components/common/ProfileCardWrapper.js +4 -2
  99. package/dist/esm/components/team-profile-card/main.js +1 -1
  100. package/dist/esm/components/team-profile-card/team-connections/main.js +3 -18
  101. package/dist/esm/components/team-profile-card/team-containers-skeleton/index.js +1 -1
  102. package/dist/esm/components/team-profile-card/team-containers-skeleton/linked-container-card-skeleton/index.js +1 -1
  103. package/dist/esm/mocks/mock-profile-client.js +10 -0
  104. package/dist/esm/mocks/profile-data.js +1 -1
  105. package/dist/esm/mocks/reporting-lines-data.js +2 -2
  106. package/dist/esm/styled/Card.js +1 -1
  107. package/dist/esm/styled/CoverImage.js +1 -1
  108. package/dist/esm/styled/Error.js +1 -1
  109. package/dist/esm/styled/ReportingLines.js +1 -1
  110. package/dist/esm/styled/TeamCard.js +1 -1
  111. package/dist/esm/styled/TeamTrigger.js +1 -1
  112. package/dist/esm/styled/UserTrigger.js +1 -1
  113. package/dist/esm/util/analytics.js +6 -2
  114. package/dist/types/client/ProfileCardClient.d.ts +2 -1
  115. package/dist/types/client/TeamCentralCardClient.d.ts +2 -2
  116. package/dist/types/client/UserProfileCardClient.d.ts +2 -1
  117. package/dist/types/components/Error/ErrorMessage.d.ts +2 -0
  118. package/dist/types/components/User/ProfileCard.d.ts +3 -2
  119. package/dist/types/components/User/ProfileCardResourced.d.ts +4 -2
  120. package/dist/types/components/User/UserLoadingState.d.ts +3 -1
  121. package/dist/types/components/User/lazyProfileCard.d.ts +1 -1
  122. package/dist/types/components/common/LoadingState.d.ts +3 -1
  123. package/dist/types/components/common/ProfileCardWrapper.d.ts +2 -1
  124. package/dist/types/components/common/types.d.ts +3 -0
  125. package/dist/types/mocks/profile-data.d.ts +1 -0
  126. package/dist/types/types.d.ts +13 -6
  127. package/dist/types/util/analytics.d.ts +5 -0
  128. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +2 -1
  129. package/dist/types-ts4.5/client/TeamCentralCardClient.d.ts +2 -2
  130. package/dist/types-ts4.5/client/UserProfileCardClient.d.ts +2 -1
  131. package/dist/types-ts4.5/components/Error/ErrorMessage.d.ts +2 -0
  132. package/dist/types-ts4.5/components/User/ProfileCard.d.ts +3 -2
  133. package/dist/types-ts4.5/components/User/ProfileCardResourced.d.ts +4 -2
  134. package/dist/types-ts4.5/components/User/UserLoadingState.d.ts +3 -1
  135. package/dist/types-ts4.5/components/User/lazyProfileCard.d.ts +1 -1
  136. package/dist/types-ts4.5/components/common/LoadingState.d.ts +3 -1
  137. package/dist/types-ts4.5/components/common/ProfileCardWrapper.d.ts +2 -1
  138. package/dist/types-ts4.5/components/common/types.d.ts +3 -0
  139. package/dist/types-ts4.5/mocks/profile-data.d.ts +1 -0
  140. package/dist/types-ts4.5/types.d.ts +13 -6
  141. package/dist/types-ts4.5/util/analytics.d.ts +5 -0
  142. package/package.json +12 -10
@@ -5,12 +5,14 @@ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import Avatar from '@atlaskit/avatar';
6
6
  import { LinkButton } from '@atlaskit/button/new';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
8
9
  import Spinner from '@atlaskit/spinner';
10
+ import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
9
11
  import { N0 } from '@atlaskit/theme/colors';
10
12
  import messages from '../../messages';
11
13
  import { ActionButtonGroup, ActionsFlexSpacer, AnimatedKudosButton, AnimationWrapper, CardContainer, CardContent, KudosBlobAnimation, ProfileImage } from '../../styled/Card';
12
14
  import { CardWrapper, SpinnerContainer } from '../../styled/UserTrigger';
13
- import { actionClicked, fireEvent, profileCardRendered } from '../../util/analytics';
15
+ import { actionClicked, fireEvent, PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
14
16
  import { isBasicClick } from '../../util/click';
15
17
  import { getPageTime } from '../../util/performance';
16
18
  import { ErrorMessage } from '../Error';
@@ -54,6 +56,9 @@ export const ProfilecardInternal = props => {
54
56
  const {
55
57
  createAnalyticsEvent
56
58
  } = props;
59
+ const {
60
+ fireEvent: fireEventNext
61
+ } = useAnalyticsEvents();
57
62
  const fireAnalytics = useCallback(payload => {
58
63
  if (createAnalyticsEvent) {
59
64
  fireEvent(createAnalyticsEvent, payload);
@@ -64,6 +69,11 @@ export const ProfilecardInternal = props => {
64
69
  const event = generator(elapsed);
65
70
  fireAnalytics(event);
66
71
  }, [fireAnalytics, openTime]);
72
+ const fireAnalyticsWithDurationNext = useCallback((eventKey, generator) => {
73
+ const duration = getPageTime() - openTime;
74
+ const attributes = generator(duration);
75
+ fireEventNext(eventKey, attributes);
76
+ }, [openTime, fireEventNext]);
67
77
  const {
68
78
  kudosAction
69
79
  } = useKudos(props.cloudId, props.userId, props.teamCentralBaseUrl, props.openKudosDrawer);
@@ -87,22 +97,33 @@ export const ProfilecardInternal = props => {
87
97
  const canRender = !hasError && !isLoading && !!(fullName || status === 'closed');
88
98
  useEffect(() => {
89
99
  if (canRender) {
90
- fireAnalyticsWithDuration(duration => profileCardRendered('user', 'content', {
91
- duration,
92
- numActions: realActions.length
93
- }));
100
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
101
+ fireAnalyticsWithDurationNext('ui.profilecard.rendered.content', duration => ({
102
+ duration,
103
+ numActions: realActions.length,
104
+ firedAt: Math.round(getPageTime()),
105
+ ...PACKAGE_META_DATA
106
+ }));
107
+ } else {
108
+ fireAnalyticsWithDuration(duration => profileCardRendered('user', 'content', {
109
+ duration,
110
+ numActions: realActions.length
111
+ }));
112
+ }
94
113
  }
95
- }, [canRender, fireAnalyticsWithDuration, realActions]);
114
+ }, [canRender, fireAnalyticsWithDuration, fireAnalyticsWithDurationNext, realActions]);
96
115
  if (hasError) {
97
116
  return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
98
117
  reload: props.clientFetchProfile,
99
118
  errorType: props.errorType || null,
100
- fireAnalytics: fireAnalytics
119
+ fireAnalytics: fireAnalytics,
120
+ fireAnalyticsNext: fireEventNext
101
121
  }));
102
122
  }
103
123
  if (isLoading) {
104
124
  return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(LoadingView, {
105
- fireAnalyticsWithDuration: fireAnalyticsWithDuration
125
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration,
126
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
106
127
  }));
107
128
  }
108
129
  if (!canRender) {
@@ -118,35 +139,51 @@ export const ProfilecardInternal = props => {
118
139
  borderColor: `var(--ds-shadow-overlay, ${N0})`
119
140
  })), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(ProfileCardDetails, _extends({}, props, {
120
141
  status: status,
121
- fireAnalyticsWithDuration: fireAnalyticsWithDuration
142
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration,
143
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
122
144
  })), realActions && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionsFlexSpacer, null), /*#__PURE__*/React.createElement(Actions, _extends({}, fg('jfp_a11y_team_profile_card_actions_label') && {
123
145
  fullName
124
146
  }, {
125
147
  fullName: fullName,
126
148
  actions: realActions,
127
149
  fireAnalyticsWithDuration: fireAnalyticsWithDuration,
128
- isTriggeredUsingKeyboard: props.isTriggeredUsingKeyboard
150
+ isTriggeredUsingKeyboard: props.isTriggeredUsingKeyboard,
151
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
129
152
  }))))));
130
153
  };
131
154
  const Actions = ({
132
155
  actions,
133
156
  fireAnalyticsWithDuration,
157
+ fireAnalyticsWithDurationNext,
134
158
  isTriggeredUsingKeyboard,
135
159
  fullName
136
160
  }) => {
137
161
  const onActionClick = useCallback((action, args, event, index) => {
138
- fireAnalyticsWithDuration(duration => actionClicked('user', {
139
- duration,
140
- hasHref: !!action.link,
141
- hasOnClick: !!action.callback,
142
- index,
143
- actionId: action.id || 'no-id-specified'
144
- }));
162
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
163
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.action', duration => ({
164
+ method: 'click',
165
+ firedAt: Math.round(getPageTime()),
166
+ duration,
167
+ hasHref: !!action.link,
168
+ hasOnClick: !!action.callback,
169
+ index,
170
+ actionId: action.id || 'no-id-specified',
171
+ ...PACKAGE_META_DATA
172
+ }));
173
+ } else {
174
+ fireAnalyticsWithDuration(duration => actionClicked('user', {
175
+ duration,
176
+ hasHref: !!action.link,
177
+ hasOnClick: !!action.callback,
178
+ index,
179
+ actionId: action.id || 'no-id-specified'
180
+ }));
181
+ }
145
182
  if (action.callback && isBasicClick(event)) {
146
183
  event.preventDefault();
147
184
  action.callback(event, ...args);
148
185
  }
149
- }, [fireAnalyticsWithDuration]);
186
+ }, [fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
150
187
  if (!actions || actions.length === 0) {
151
188
  return null;
152
189
  }
@@ -175,21 +212,31 @@ const Actions = ({
175
212
  }), overflowActions && /*#__PURE__*/React.createElement(OverflowProfileCardButtons, _extends({
176
213
  actions: overflowActions,
177
214
  fireAnalyticsWithDuration: fireAnalyticsWithDuration,
215
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext,
178
216
  onItemClick: (action, args, event, index) => onActionClick(action, args, event, index + ACTION_OVERFLOW_THRESHOLD)
179
217
  }, fg('jfp_a11y_team_profile_card_actions_label') && {
180
218
  fullName
181
219
  })));
182
220
  };
183
- const LoadingView = ({
184
- fireAnalyticsWithDuration
221
+ export const LoadingView = ({
222
+ fireAnalyticsWithDuration,
223
+ fireAnalyticsWithDurationNext
185
224
  }) => {
186
225
  useEffect(() => {
187
- fireAnalyticsWithDuration(duration => profileCardRendered('user', 'spinner', {
188
- duration
189
- }));
190
- }, [fireAnalyticsWithDuration]);
226
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
227
+ fireAnalyticsWithDurationNext('ui.profilecard.rendered.spinner', duration => ({
228
+ firedAt: Math.round(getPageTime()),
229
+ duration,
230
+ ...PACKAGE_META_DATA
231
+ }));
232
+ } else {
233
+ fireAnalyticsWithDuration(duration => profileCardRendered('user', 'spinner', {
234
+ duration
235
+ }));
236
+ }
237
+ }, [fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
191
238
  return /*#__PURE__*/React.createElement(SpinnerContainer, {
192
239
  testId: "profilecard-spinner-container"
193
240
  }, /*#__PURE__*/React.createElement(Spinner, null));
194
241
  };
195
- export default withAnalyticsEvents()(ProfilecardInternal);
242
+ export default componentWithFG('ptc-enable-profile-card-analytics-refactor', ProfilecardInternal, withAnalyticsEvents()(ProfilecardInternal));
@@ -1,4 +1,4 @@
1
- /* ProfileCardDetails.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* ProfileCardDetails.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./ProfileCardDetails.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -137,6 +137,7 @@ export const ProfileCardDetails = props => {
137
137
  reportingLines: props.reportingLines,
138
138
  reportingLinesProfileUrl: props.reportingLinesProfileUrl,
139
139
  onReportingLinesClick: props.onReportingLinesClick,
140
- fireAnalyticsWithDuration: props.fireAnalyticsWithDuration
140
+ fireAnalyticsWithDuration: props.fireAnalyticsWithDuration,
141
+ fireAnalyticsWithDurationNext: props.fireAnalyticsWithDurationNext
141
142
  }));
142
143
  };
@@ -3,6 +3,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React, { Suspense } from 'react';
4
4
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
6
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
7
+ import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
6
8
  import filterActions from '../../internal/filterActions';
7
9
  import { CardWrapper } from '../../styled/UserTrigger';
8
10
  import { fireEvent } from '../../util/analytics';
@@ -33,6 +35,15 @@ class ProfileCardResourced extends React.PureComponent {
33
35
  fireEvent(this.props.createAnalyticsEvent, payload);
34
36
  }
35
37
  });
38
+ _defineProperty(this, "fireAnalyticsNext", (eventKey, ...attributes) => {
39
+ // Don't fire analytics if the component is unmounted
40
+ if (!this._isMounted) {
41
+ return;
42
+ }
43
+ if (this.props.fireEvent) {
44
+ this.props.fireEvent(eventKey, ...attributes);
45
+ }
46
+ });
36
47
  _defineProperty(this, "clientFetchProfile", () => {
37
48
  const {
38
49
  cloudId,
@@ -50,7 +61,7 @@ class ProfileCardResourced extends React.PureComponent {
50
61
  hasError: false,
51
62
  data: null
52
63
  }, () => {
53
- const requests = Promise.all([this.props.resourceClient.getProfile(cloudId, userId, this.fireAnalytics), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos(), this.props.resourceClient.getTeamCentralBaseUrl({
64
+ const requests = Promise.all([this.props.resourceClient.getProfile(cloudId, userId, this.fireAnalytics, this.fireAnalyticsNext), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos(), this.props.resourceClient.getTeamCentralBaseUrl({
54
65
  withOrgContext: true,
55
66
  withSiteContext: true
56
67
  })]);
@@ -130,7 +141,8 @@ class ProfileCardResourced extends React.PureComponent {
130
141
  const isFetchingOrNotStartToFetchYet = isLoading === true || isLoading === undefined;
131
142
  if (isFetchingOrNotStartToFetchYet) {
132
143
  return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, {
133
- fireAnalytics: this.fireAnalytics
144
+ fireAnalytics: this.fireAnalytics,
145
+ fireAnalyticsNext: this.fireAnalyticsNext
134
146
  }));
135
147
  } else if (hasError) {
136
148
  return /*#__PURE__*/React.createElement(CardWrapper, {
@@ -138,7 +150,8 @@ class ProfileCardResourced extends React.PureComponent {
138
150
  }, /*#__PURE__*/React.createElement(ErrorMessage, {
139
151
  errorType: error,
140
152
  reload: this.clientFetchProfile,
141
- fireAnalytics: this.fireAnalytics
153
+ fireAnalytics: this.fireAnalytics,
154
+ fireAnalyticsNext: this.fireAnalyticsNext
142
155
  }));
143
156
  }
144
157
  const newProps = {
@@ -177,4 +190,12 @@ _defineProperty(ProfileCardResourced, "defaultProps", {
177
190
  actions: []
178
191
  });
179
192
  export const ProfileCardResourcedInternal = ProfileCardResourced;
180
- export default withAnalyticsEvents()(ProfileCardResourced);
193
+ const ProfileCardResourcedWithAnalytics = props => {
194
+ const {
195
+ fireEvent
196
+ } = useAnalyticsEvents();
197
+ return /*#__PURE__*/React.createElement(ProfileCardResourced, _extends({
198
+ fireEvent: fireEvent
199
+ }, props));
200
+ };
201
+ export default componentWithFG('ptc-enable-profile-card-analytics-refactor', ProfileCardResourcedWithAnalytics, withAnalyticsEvents()(ProfileCardResourced));
@@ -1,4 +1,4 @@
1
- /* ProfileCardTrigger.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* ProfileCardTrigger.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./ProfileCardTrigger.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -9,12 +9,14 @@ import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import Popup from '@atlaskit/popup';
11
11
  import { Box } from '@atlaskit/primitives/compiled';
12
+ import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/teams-app-internal-analytics';
12
13
  import { layers } from '@atlaskit/theme/constants';
13
14
  import filterActionsInner from '../../internal/filterActions';
14
15
  import getLabelMessage from '../../internal/getLabelMessage';
15
16
  import { CardWrapper } from '../../styled/UserTrigger';
16
- import { cardTriggered, fireEvent } from '../../util/analytics';
17
+ import { cardTriggered, fireEvent, PACKAGE_META_DATA } from '../../util/analytics';
17
18
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
19
+ import { getPageTime } from '../../util/performance';
18
20
  import { AgentProfileCardResourced } from '../Agent/AgentProfileCardResourced';
19
21
  import { ProfileCardLazy } from './lazyProfileCard';
20
22
  import UserLoadingState from './UserLoadingState';
@@ -105,6 +107,9 @@ export default function ProfilecardTriggerNext({
105
107
  const [kudosDrawerOpen, setKudosDrawerOpen] = useState(false);
106
108
  const [isTriggeredUsingKeyboard, setTriggeredUsingKeyboard] = useState(false);
107
109
  const triggerRef = useRef(null);
110
+ const {
111
+ fireEvent: fireEventNext
112
+ } = useAnalyticsEventsNext();
108
113
  useEffect(() => {
109
114
  isMounted.current = true;
110
115
  return () => {
@@ -123,6 +128,14 @@ export default function ProfilecardTriggerNext({
123
128
  setShouldShowGiveKudos(false);
124
129
  setTeamCentralBaseUrl(undefined);
125
130
  }, [userId]);
131
+
132
+ // Create a wrapper function that has the same interface as fireEventNext but includes isMounted check
133
+ const fireAnalyticsNext = useCallback((eventKey, ...attributes) => {
134
+ if (!isMounted.current) {
135
+ return;
136
+ }
137
+ fireEventNext(eventKey, ...attributes);
138
+ }, [fireEventNext]);
126
139
  const fireAnalytics = useCallback(payload => {
127
140
  // Don't fire any analytics if the component is unmounted
128
141
  if (!isMounted.current) {
@@ -180,7 +193,7 @@ export default function ProfilecardTriggerNext({
180
193
  setError(null);
181
194
  setData(null);
182
195
  try {
183
- const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl({
196
+ const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics, fireAnalyticsNext), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl({
184
197
  withOrgContext: true,
185
198
  withSiteContext: true
186
199
  })]);
@@ -189,7 +202,7 @@ export default function ProfilecardTriggerNext({
189
202
  } catch (err) {
190
203
  handleClientError(err);
191
204
  }
192
- }, [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
205
+ }, [cloudId, fireAnalytics, fireAnalyticsNext, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
193
206
  const showProfilecard = useCallback(() => {
194
207
  clearTimeout(hideTimer.current);
195
208
  clearTimeout(showTimer.current);
@@ -208,25 +221,49 @@ export default function ProfilecardTriggerNext({
208
221
  event.stopPropagation();
209
222
  showProfilecard();
210
223
  if (!visible) {
211
- fireAnalytics(cardTriggered('user', 'click'));
224
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
225
+ fireAnalyticsNext('ui.profilecard.triggered', {
226
+ method: 'click',
227
+ firedAt: Math.round(getPageTime()),
228
+ ...PACKAGE_META_DATA
229
+ });
230
+ } else {
231
+ fireAnalytics(cardTriggered('user', 'click'));
232
+ }
212
233
  }
213
- }, [fireAnalytics, showProfilecard, visible]);
234
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
214
235
  const onMouseEnter = useCallback(() => {
215
236
  showProfilecard();
216
237
  if (!visible) {
217
- fireAnalytics(cardTriggered('user', 'hover'));
238
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
239
+ fireAnalyticsNext('ui.profilecard.triggered', {
240
+ method: 'hover',
241
+ firedAt: Math.round(getPageTime()),
242
+ ...PACKAGE_META_DATA
243
+ });
244
+ } else {
245
+ fireAnalytics(cardTriggered('user', 'hover'));
246
+ }
218
247
  }
219
- }, [fireAnalytics, showProfilecard, visible]);
248
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
220
249
  const onKeyPress = useCallback(event => {
221
250
  if (event.key === 'Enter' || event.key === ' ') {
222
251
  event.preventDefault();
223
252
  setTriggeredUsingKeyboard(true);
224
253
  showProfilecard();
225
254
  if (!visible) {
226
- fireAnalytics(cardTriggered('user', 'click'));
255
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
256
+ fireAnalyticsNext('ui.profilecard.triggered', {
257
+ method: 'click',
258
+ firedAt: Math.round(getPageTime()),
259
+ ...PACKAGE_META_DATA
260
+ });
261
+ } else {
262
+ fireAnalytics(cardTriggered('user', 'click'));
263
+ }
227
264
  }
228
265
  }
229
- }, [fireAnalytics, showProfilecard, visible]);
266
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
230
267
  const onFocus = useCallback(() => {
231
268
  showProfilecard();
232
269
  }, [showProfilecard]);
@@ -301,7 +338,8 @@ export default function ProfilecardTriggerNext({
301
338
  placement: position,
302
339
  offset: offset !== null && offset !== void 0 ? offset : [0, 8],
303
340
  content: () => /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
304
- fireAnalytics: fireAnalytics
341
+ fireAnalytics: fireAnalytics,
342
+ fireAnalyticsNext: fireAnalyticsNext
305
343
  }) : visible && /*#__PURE__*/React.createElement(ProfileCardContent, {
306
344
  profilecardProps: profilecardProps,
307
345
  isAgent: !!(data !== null && data !== void 0 && data.isAgent),
@@ -378,7 +416,8 @@ export default function ProfilecardTriggerNext({
378
416
  placement: position,
379
417
  offset: offset !== null && offset !== void 0 ? offset : [0, 8],
380
418
  content: () => /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
381
- fireAnalytics: fireAnalytics
419
+ fireAnalytics: fireAnalytics,
420
+ fireAnalyticsNext: fireAnalyticsNext
382
421
  }) : visible && /*#__PURE__*/React.createElement(ProfileCardContent, {
383
422
  profilecardProps: profilecardProps,
384
423
  isAgent: !!(data !== null && data !== void 0 && data.isAgent),
@@ -447,9 +486,11 @@ export default function ProfilecardTriggerNext({
447
486
  })));
448
487
  }
449
488
  const LoadingView = ({
450
- fireAnalytics
489
+ fireAnalytics,
490
+ fireAnalyticsNext
451
491
  }) => /*#__PURE__*/React.createElement(CardWrapper, {
452
492
  testId: "profilecard.profilecardtrigger.loading"
453
493
  }, /*#__PURE__*/React.createElement(UserLoadingState, {
454
- fireAnalytics: fireAnalytics
494
+ fireAnalytics: fireAnalytics,
495
+ fireAnalyticsNext: fireAnalyticsNext
455
496
  }));
@@ -1,16 +1,18 @@
1
- /* ReportingLinesDetails.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* ReportingLinesDetails.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import "./ReportingLinesDetails.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
5
  import { FormattedMessage, useIntl } from 'react-intl-next';
6
6
  import Avatar from '@atlaskit/avatar';
7
7
  import AvatarGroup from '@atlaskit/avatar-group';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
9
10
  import { Box, xcss } from '@atlaskit/primitives';
10
11
  import { Pressable } from '@atlaskit/primitives/compiled';
11
12
  import messages from '../../messages';
12
13
  import { ManagerName, ManagerSection, OffsetWrapper, ReportingLinesSection } from '../../styled/ReportingLines';
13
- import { reportingLinesClicked } from '../../util/analytics';
14
+ import { PACKAGE_META_DATA, reportingLinesClicked } from '../../util/analytics';
15
+ import { getPageTime } from '../../util/performance';
14
16
  function getProfileHref(userId, profileUrl) {
15
17
  return profileUrl ? profileUrl + userId : undefined;
16
18
  }
@@ -34,6 +36,7 @@ const ReportingLinesDetails = props => {
34
36
  } = useIntl();
35
37
  const {
36
38
  fireAnalyticsWithDuration,
39
+ fireAnalyticsWithDurationNext,
37
40
  reportingLines = {},
38
41
  reportingLinesProfileUrl,
39
42
  onReportingLinesClick
@@ -45,10 +48,19 @@ const ReportingLinesDetails = props => {
45
48
  const manager = managers.length >= 1 ? managers[0] : undefined;
46
49
  const hasReports = reports.length > 0;
47
50
  const getReportingLinesOnClick = (user, userType) => onReportingLinesClick ? () => {
48
- fireAnalyticsWithDuration(duration => reportingLinesClicked({
49
- duration,
50
- userType
51
- }));
51
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
52
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.reportingLines', duration => ({
53
+ duration,
54
+ userType,
55
+ firedAt: Math.round(getPageTime()),
56
+ ...PACKAGE_META_DATA
57
+ }));
58
+ } else {
59
+ fireAnalyticsWithDuration(duration => reportingLinesClicked({
60
+ duration,
61
+ userType
62
+ }));
63
+ }
52
64
  onReportingLinesClick(user);
53
65
  } : undefined;
54
66
  const onReportingLinksClick = (user, userType, href) => {
@@ -56,10 +68,19 @@ const ReportingLinesDetails = props => {
56
68
  if (onReportingLinesClick) {
57
69
  shouldPreventDefault = onReportingLinesClick(user) === false;
58
70
  }
59
- fireAnalyticsWithDuration(duration => reportingLinesClicked({
60
- duration,
61
- userType
62
- }));
71
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
72
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.reportingLines', duration => ({
73
+ duration,
74
+ userType,
75
+ firedAt: Math.round(getPageTime()),
76
+ ...PACKAGE_META_DATA
77
+ }));
78
+ } else {
79
+ fireAnalyticsWithDuration(duration => reportingLinesClicked({
80
+ duration,
81
+ userType
82
+ }));
83
+ }
63
84
  if (shouldPreventDefault) {
64
85
  return;
65
86
  }
@@ -1,13 +1,23 @@
1
1
  import React, { useEffect } from 'react';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import AkSpinner from '@atlaskit/spinner';
3
4
  import { SpinnerContainer } from '../../styled/UserTrigger';
4
- import { profileCardRendered } from '../../util/analytics';
5
+ import { PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
6
+ import { getPageTime } from '../../util/performance';
5
7
  const UserLoadingState = ({
6
- fireAnalytics
8
+ fireAnalytics,
9
+ fireAnalyticsNext
7
10
  }) => {
8
11
  useEffect(() => {
9
- fireAnalytics(profileCardRendered('user', 'spinner'));
10
- }, [fireAnalytics]);
12
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
13
+ fireAnalyticsNext('ui.profilecard.rendered.spinner', {
14
+ firedAt: Math.round(getPageTime()),
15
+ ...PACKAGE_META_DATA
16
+ });
17
+ } else {
18
+ fireAnalytics(profileCardRendered('user', 'spinner'));
19
+ }
20
+ }, [fireAnalytics, fireAnalyticsNext]);
11
21
  return /*#__PURE__*/React.createElement(SpinnerContainer, null, /*#__PURE__*/React.createElement(AkSpinner, null));
12
22
  };
13
23
  export default UserLoadingState;
@@ -1,15 +1,27 @@
1
1
  import React, { useEffect } from 'react';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import AkSpinner from '@atlaskit/spinner';
3
4
  import { SpinnerContainer } from '../../styled/UserTrigger';
4
- import { profileCardRendered } from '../../util/analytics';
5
+ import { getActionSubject, PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
6
+ import { getPageTime } from '../../util/performance';
5
7
  export const LoadingState = ({
6
8
  fireAnalytics,
9
+ fireAnalyticsNext,
7
10
  profileType
8
11
  }) => {
9
12
  useEffect(() => {
10
- if (fireAnalytics) {
11
- fireAnalytics(profileCardRendered(profileType, 'spinner'));
13
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
14
+ if (fireAnalyticsNext) {
15
+ fireAnalyticsNext(`ui.${getActionSubject(profileType)}.rendered.spinner`, {
16
+ firedAt: Math.round(getPageTime()),
17
+ ...PACKAGE_META_DATA
18
+ });
19
+ }
20
+ } else {
21
+ if (fireAnalytics) {
22
+ fireAnalytics(profileCardRendered(profileType, 'spinner'));
23
+ }
12
24
  }
13
- }, [fireAnalytics, profileType]);
25
+ }, [fireAnalytics, fireAnalyticsNext, profileType]);
14
26
  return /*#__PURE__*/React.createElement(SpinnerContainer, null, /*#__PURE__*/React.createElement(AkSpinner, null));
15
27
  };
@@ -1,8 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import Popup from '@atlaskit/popup';
4
5
  import { layers } from '@atlaskit/theme/constants';
5
- import { cardTriggered } from '../../util/analytics';
6
+ import { cardTriggered, getActionSubject, PACKAGE_META_DATA } from '../../util/analytics';
7
+ import { getPageTime } from '../../util/performance';
6
8
  import { useProfileInfo } from '../../util/useProfileInfo';
7
9
  import { LoadingState } from './LoadingState';
8
10
  import { PopupTrigger } from './PopupTrigger';
@@ -17,7 +19,9 @@ function ProfileCardTriggerInner({
17
19
  fetchProfile,
18
20
  disabledAriaAttributes,
19
21
  profileCardType,
22
+ testId,
20
23
  fireAnalytics,
24
+ fireAnalyticsNext,
21
25
  ...popupProps
22
26
  }, ref) {
23
27
  var _popupProps$autoFocus;
@@ -57,12 +61,22 @@ function ProfileCardTriggerInner({
57
61
  if (!visible) {
58
62
  getProfileData === null || getProfileData === void 0 ? void 0 : getProfileData();
59
63
  setVisible(true);
60
- if (fireAnalytics) {
61
- fireAnalytics(cardTriggered(profileCardType, trigger));
64
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
65
+ if (fireAnalyticsNext) {
66
+ fireAnalyticsNext(`ui.${getActionSubject(profileCardType)}.triggered`, {
67
+ method: trigger,
68
+ ...PACKAGE_META_DATA,
69
+ firedAt: Math.round(getPageTime())
70
+ });
71
+ }
72
+ } else {
73
+ if (fireAnalytics) {
74
+ fireAnalytics(cardTriggered(profileCardType, trigger));
75
+ }
62
76
  }
63
77
  }
64
78
  }, showDelay);
65
- }, [showDelay, visible, getProfileData, fireAnalytics, profileCardType, trigger]);
79
+ }, [showDelay, visible, getProfileData, fireAnalytics, profileCardType, trigger, fireAnalyticsNext]);
66
80
  const onMouseEnter = useCallback(() => {
67
81
  showProfilecard();
68
82
  }, [showProfilecard]);
@@ -85,7 +99,8 @@ function ProfileCardTriggerInner({
85
99
  showProfilecard: showProfilecard,
86
100
  children: children,
87
101
  ariaLabelledBy: ariaLabelledBy,
88
- trigger: trigger
102
+ trigger: trigger,
103
+ "data-testid": testId
89
104
  }));
90
105
  },
91
106
  content: () =>
@@ -94,9 +109,13 @@ function ProfileCardTriggerInner({
94
109
  React.createElement("div", {
95
110
  onMouseEnter: onMouseEnter,
96
111
  onMouseLeave: hideProfilecard,
97
- onFocus: showProfilecard
98
- }, isLoading ? /*#__PURE__*/React.createElement(ProfileCardWrapper, null, /*#__PURE__*/React.createElement(LoadingState, {
112
+ onFocus: showProfilecard,
113
+ "data-testid": "profile-card--trigger-content"
114
+ }, isLoading ? /*#__PURE__*/React.createElement(ProfileCardWrapper, {
115
+ testId: "profilecard.profilecardtrigger.loading"
116
+ }, /*#__PURE__*/React.createElement(LoadingState, {
99
117
  fireAnalytics: fireAnalytics,
118
+ fireAnalyticsNext: fireAnalyticsNext,
100
119
  profileType: profileCardType
101
120
  })) : renderProfileCard({
102
121
  profileData,
@@ -6,9 +6,11 @@ const styles = xcss({
6
6
  width: '360px'
7
7
  });
8
8
  export const ProfileCardWrapper = ({
9
- children
9
+ children,
10
+ testId
10
11
  }) => {
11
12
  return /*#__PURE__*/React.createElement(Box, {
12
- xcss: styles
13
+ xcss: styles,
14
+ testId: testId
13
15
  }, children);
14
16
  };
@@ -1,4 +1,4 @@
1
- /* main.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* main.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./main.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";