Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(insights): add analytics to database sample panel #70769

Merged
merged 6 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions static/app/utils/analytics/performanceAnalyticsEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {FieldValue} from 'sentry/components/forms/model';
import type {Organization, PlatformKey} from 'sentry/types';

type SampleTransactionParam = {
Expand Down Expand Up @@ -127,6 +128,24 @@ export type PerformanceEventParameters = {
'performance_views.relative_breakdown.selection': {
action: string;
};
'performance_views.sample_spans.filter_updated': {
filter: string;
new_state: FieldValue;
organization: Organization;
source: string;
};
'performance_views.sample_spans.opened': {
organization: Organization;
source: string;
};
'performance_views.sample_spans.span_clicked': {
organization: Organization;
source: string;
};
'performance_views.sample_spans.try_different_samples_clicked': {
organization: Organization;
source: string;
};
'performance_views.span_summary.change_chart': {
change_to_display: string;
};
Expand Down Expand Up @@ -253,6 +272,12 @@ export const performanceEventMap: Record<PerformanceEventKey, string | null> = {
'performance_views.landingv3.table_pagination':
'Performance Views: Landing Page Transactions Table Page Changed',
'performance_views.overview.change_chart': 'Performance Views: Change Overview Chart',
'performance_views.sample_spans.opened': 'Performance Views: Sample spans panel opened',
'performance_views.sample_spans.span_clicked': 'Performance Views: Sample span clicked',
'performance_views.sample_spans.try_different_samples_clicked':
'Performance Views: Try Different Samples clicked',
'performance_views.sample_spans.filter_updated':
'Performance Views: Sample spans panel filter updated',
'performance_views.span_summary.change_chart':
'Performance Views: Span Summary displayed chart changed',
'performance_views.spans.change_op': 'Performance Views: Change span operation name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function ResourceSummary() {
<SampleList
transactionRoute="/performance/browser/pageloads/"
groupId={groupId}
moduleName="resources"
transactionName={transaction as string}
additionalFields={[HTTP_RESPONSE_CONTENT_LENGTH]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export function DatabaseSpanSummaryPage({params}: Props) {

<SampleList
groupId={span[SpanMetricsField.SPAN_GROUP]}
moduleName="database"
transactionName={transaction}
transactionMethod={transactionMethod}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {CursorHandler} from 'sentry/components/pagination';
import Pagination from 'sentry/components/pagination';
import {t} from 'sentry/locale';
import type {Organization} from 'sentry/types';
import {trackAnalytics} from 'sentry/utils/analytics';
import type {EventsMetaType} from 'sentry/utils/discover/eventView';
import {getFieldRenderer} from 'sentry/utils/discover/fieldRenderers';
import type {Sort} from 'sentry/utils/discover/fields';
Expand Down Expand Up @@ -161,7 +162,17 @@ function renderBodyCell(

return (
<OverflowEllipsisTextContainer>
<Link to={`${pathname}?${qs.stringify(query)}`}>{label}</Link>
<Link
onClick={() =>
trackAnalytics('performance_views.sample_spans.opened', {
organization,
source: 'database',
})
}
to={`${pathname}?${qs.stringify(query)}`}
>
{label}
</Link>
</OverflowEllipsisTextContainer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export function ScreenLoadSampleContainer({
onMouseOverSample={sample => setHighlightedSpanId(sample.span_id)}
groupId={groupId}
transactionName={transactionName}
moduleName="screenLoad"
release={release}
columnOrder={[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Link from 'sentry/components/links/link';
import {Tooltip} from 'sentry/components/tooltip';
import {IconProfiling} from 'sentry/icons/iconProfiling';
import {t} from 'sentry/locale';
import {trackAnalytics} from 'sentry/utils/analytics';
import {generateLinkToEventInTraceView} from 'sentry/utils/discover/urls';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
Expand Down Expand Up @@ -67,6 +68,7 @@ type Props = {
avg: number;
data: SpanTableRow[];
isLoading: boolean;
moduleName: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a moduleName type here, that we should probably use instead of string
https://github.com/getsentry/sentry/blob/master/static/app/views/starfish/types.tsx#L13
Although its missing a bunch of modules, so we could extend that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this! If you add the missing modules to ModuleName and use ModuleName instead of strings that'd be great 👍🏻

columnOrder?: SamplesTableColumnHeader[];
highlightedSpanId?: string;
onMouseLeaveSample?: () => void;
Expand All @@ -77,6 +79,7 @@ export function SpanSamplesTable({
isLoading,
data,
avg,
moduleName,
highlightedSpanId,
onMouseLeaveSample,
onMouseOverSample,
Expand Down Expand Up @@ -123,6 +126,12 @@ export function SpanSamplesTable({
if (column.key === 'span_id') {
return (
<Link
onClick={() =>
trackAnalytics('performance_views.sample_spans.span_clicked', {
organization,
source: moduleName,
})
}
to={generateLinkToEventInTraceView({
eventId: row['transaction.id'],
timestamp: row.timestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {HTTP_RESPONSE_CONTENT_LENGTH} = SpanMetricsField;

type Props = {
groupId: string;
moduleName: string;
transactionName: string;
additionalFields?: string[];
onClose?: () => void;
Expand All @@ -37,6 +38,7 @@ type Props = {

export function SampleList({
groupId,
moduleName,
transactionName,
transactionMethod,
spanDescription,
Expand Down Expand Up @@ -171,6 +173,7 @@ export function SampleList({
onMouseLeaveSample={() => setHighlightedSpanId(undefined)}
onMouseOverSample={sample => setHighlightedSpanId(sample.span_id)}
groupId={groupId}
moduleName={moduleName}
transactionName={transactionName}
query={extraQuery}
columnOrder={columnOrder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('SampleTable', function () {
const container = render(
<SampleTable
groupId="groupId123"
moduleName="sampleModule"
transactionMethod="GET"
transactionName="/endpoint"
/>
Expand All @@ -55,6 +56,7 @@ describe('SampleTable', function () {
const container = render(
<SampleTable
groupId="groupId123"
moduleName="sampleModule"
transactionMethod="GET"
transactionName="/endpoint"
/>
Expand All @@ -68,6 +70,7 @@ describe('SampleTable', function () {
const container = render(
<SampleTable
groupId="groupId123"
moduleName="sampleModule"
transactionMethod="GET"
transactionName="/endpoint"
/>
Expand All @@ -89,6 +92,7 @@ describe('SampleTable', function () {
const container = render(
<SampleTable
groupId="groupId123"
moduleName="sampleModule"
transactionMethod="GET"
transactionName="/endpoint"
columnOrder={[
Expand Down Expand Up @@ -137,6 +141,7 @@ describe('SampleTable', function () {
const container = render(
<SampleTable
groupId="groupId123"
moduleName="sampleModule"
transactionMethod="GET"
transactionName="/endpoint"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const SpanSamplesTableContainer = styled('div')`

type Props = {
groupId: string;
moduleName: string;
transactionName: string;
additionalFields?: string[];
additionalFilters?: Record<string, string>;
Expand All @@ -41,6 +42,7 @@ type Props = {

function SampleTable({
groupId,
moduleName,
transactionName,
highlightedSpanId,
onMouseLeaveSample,
Expand Down Expand Up @@ -152,6 +154,7 @@ function SampleTable({
hasData={spans.length > 0}
>
<SpanSamplesTable
moduleName={moduleName}
onMouseLeaveSample={onMouseLeaveSample}
onMouseOverSample={onMouseOverSample}
highlightedSpanId={highlightedSpanId}
Expand All @@ -167,7 +170,17 @@ function SampleTable({
avg={spanMetrics?.[`avg(${SPAN_SELF_TIME})`]}
/>
</VisuallyCompleteWithData>
<Button onClick={() => refetch()}>{t('Try Different Samples')}</Button>
<Button
onClick={() => {
trackAnalytics('performance_views.sample_spans.try_different_samples_clicked', {
organization,
source: moduleName,
});
refetch();
}}
>
{t('Try Different Samples')}
</Button>
</SpanSamplesTableContainer>
);
}
Expand Down
Loading