|
@@ -26,17 +26,12 @@ interface Props {
|
|
|
export function EventCause({group, eventId, project, commitRow: CommitRow}: Props) {
|
|
|
const organization = useOrganization();
|
|
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
|
- const {data, isLoading} = useCommitters({
|
|
|
+ const {data} = useCommitters({
|
|
|
eventId,
|
|
|
projectSlug: project.slug,
|
|
|
});
|
|
|
const committers = data?.committers ?? [];
|
|
|
|
|
|
- useRouteAnalyticsParams({
|
|
|
- fetching: isLoading,
|
|
|
- num_suspect_commits: committers.length,
|
|
|
- });
|
|
|
-
|
|
|
function getUniqueCommitsWithAuthors() {
|
|
|
// Get a list of commits with author information attached
|
|
|
const commitsWithAuthors = flatMap(committers, ({commits, author}) =>
|
|
@@ -50,29 +45,38 @@ export function EventCause({group, eventId, project, commitRow: CommitRow}: Prop
|
|
|
return uniqBy(commitsWithAuthors, commit => commit.id);
|
|
|
}
|
|
|
|
|
|
+ const commits = getUniqueCommitsWithAuthors();
|
|
|
+
|
|
|
+ useRouteAnalyticsParams({
|
|
|
+ num_suspect_commits: commits.length,
|
|
|
+ suspect_commit_calculation: commits[0]?.suspectCommitType ?? 'no suspect commit',
|
|
|
+ });
|
|
|
+
|
|
|
if (!committers.length) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- const handlePullRequestClick = () => {
|
|
|
+ const handlePullRequestClick = (commit: Commit, commitIndex: number) => {
|
|
|
trackAnalytics('issue_details.suspect_commits.pull_request_clicked', {
|
|
|
organization,
|
|
|
project_id: parseInt(project.id as string, 10),
|
|
|
+ suspect_commit_calculation: commit.suspectCommitType ?? 'unknown',
|
|
|
+ suspect_commit_index: commitIndex,
|
|
|
...getAnalyticsDataForGroup(group),
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const handleCommitClick = (commit: Commit) => {
|
|
|
+ const handleCommitClick = (commit: Commit, commitIndex: number) => {
|
|
|
trackAnalytics('issue_details.suspect_commits.commit_clicked', {
|
|
|
organization,
|
|
|
project_id: parseInt(project.id as string, 10),
|
|
|
has_pull_request: commit.pullRequest?.id !== undefined,
|
|
|
+ suspect_commit_calculation: commit.suspectCommitType ?? 'unknown',
|
|
|
+ suspect_commit_index: commitIndex,
|
|
|
...getAnalyticsDataForGroup(group),
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const commits = getUniqueCommitsWithAuthors();
|
|
|
-
|
|
|
const commitHeading = tn('Suspect Commit', 'Suspect Commits (%s)', commits.length);
|
|
|
|
|
|
return (
|
|
@@ -97,12 +101,12 @@ export function EventCause({group, eventId, project, commitRow: CommitRow}: Prop
|
|
|
)}
|
|
|
</CauseHeader>
|
|
|
<StyledPanel>
|
|
|
- {commits.slice(0, isExpanded ? 100 : 1).map(commit => (
|
|
|
+ {commits.slice(0, isExpanded ? 100 : 1).map((commit, commitIndex) => (
|
|
|
<CommitRow
|
|
|
key={commit.id}
|
|
|
commit={commit}
|
|
|
- onCommitClick={handleCommitClick}
|
|
|
- onPullRequestClick={handlePullRequestClick}
|
|
|
+ onCommitClick={() => handleCommitClick(commit, commitIndex)}
|
|
|
+ onPullRequestClick={() => handlePullRequestClick(commit, commitIndex)}
|
|
|
/>
|
|
|
))}
|
|
|
</StyledPanel>
|