Skip to content

Commit

Permalink
chore(issue-details): Add analytics to issue breadcrumb (#85179)
Browse files Browse the repository at this point in the history
add analytics to dropdown items in the issue details breadcrumb
  • Loading branch information
roggenkemper authored Feb 13, 2025
1 parent d204488 commit cbcb6e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
10 changes: 10 additions & 0 deletions static/app/utils/analytics/issueAnalyticsEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ interface GroupEventParams extends CommonGroupAnalyticsData, BaseEventAnalyticsP
interface StreamlineGroupEventParams extends GroupEventParams {
streamline: boolean;
}
interface StreamlineGroupParams extends CommonGroupAnalyticsData {
streamline: boolean;
}

interface EventDropdownParams {
event_id: string;
Expand Down Expand Up @@ -110,6 +113,9 @@ export type IssueEventParameters = {
};
'issue_details.copy_event_id_clicked': StreamlineGroupEventParams;
'issue_details.copy_event_link_clicked': StreamlineGroupEventParams;
'issue_details.copy_issue_markdown_link_clicked': StreamlineGroupParams;
'issue_details.copy_issue_short_id_clicked': StreamlineGroupParams;
'issue_details.copy_issue_url_clicked': StreamlineGroupParams;
'issue_details.escalating_feedback_received': {
group_id: string;
is_high_priority: boolean;
Expand Down Expand Up @@ -386,6 +392,10 @@ export const issueEventMap: Record<IssueEventKey, string | null> = {
'highlights.issue_details.view_all_clicked': 'Highlights: View All Clicked',
'highlights.project_settings.updated_manually':
'Highlights: Updated Manually from Settings',
'issue_details.copy_issue_short_id_clicked': 'Issue Details: Copy Issue Short ID',
'issue_details.copy_issue_url_clicked': 'Issue Details: Copy Issue URL',
'issue_details.copy_issue_markdown_link_clicked':
'Issue Details: Copy Issue Markdown Link',
'issue_details.escalating_feedback_received':
'Issue Details: Escalating Feedback Received',
'issue_details.escalating_issues_banner_feedback_received':
Expand Down
26 changes: 25 additions & 1 deletion static/app/views/issueDetails/shortIdBreadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import {space} from 'sentry/styles/space';
import type {Group} from 'sentry/types/group';
import type {Organization} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {trackAnalytics} from 'sentry/utils/analytics';
import {getAnalyticsDataForGroup} from 'sentry/utils/events';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import useCopyToClipboard from 'sentry/utils/useCopyToClipboard';
import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';

interface ShortIdBreadcrumbProps {
group: Group;
Expand All @@ -24,23 +27,44 @@ export function ShortIdBreadcrumb({
project,
group,
}: ShortIdBreadcrumbProps) {
const hasStreamlinedUI = useHasStreamlinedUI();
const {onClick: handleCopyShortId} = useCopyToClipboard({
text: group.shortId,
successMessage: t('Copied Short-ID to clipboard'),
onCopy: () => {
trackAnalytics('issue_details.copy_issue_short_id_clicked', {
organization,
...getAnalyticsDataForGroup(group),
streamline: hasStreamlinedUI,
});
},
});

const issueUrl =
window.location.origin +
normalizeUrl(`/organizations/${organization.slug}/issues/${group.id}/`);

const {onClick: handleCopyUrl} = useCopyToClipboard({
text: issueUrl,
successMessage: t('Copied Issue URL to clipboard'),
onCopy: () => {
trackAnalytics('issue_details.copy_issue_url_clicked', {
organization,
...getAnalyticsDataForGroup(group),
streamline: hasStreamlinedUI,
});
},
});

const {onClick: handleCopyMarkdown} = useCopyToClipboard({
text: `[${group.shortId}](${issueUrl})`,
successMessage: t('Copied Markdown Issue Link to clipboard'),
onCopy: () => {
trackAnalytics('issue_details.copy_issue_markdown_link_clicked', {
organization,
...getAnalyticsDataForGroup(group),
streamline: hasStreamlinedUI,
});
},
});

if (!group.shortId) {
Expand Down

0 comments on commit cbcb6e7

Please sign in to comment.