Skip to content

Commit

Permalink
add analytics to cache sample panel
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinL10 committed May 14, 2024
1 parent 716a276 commit ab95284
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
14 changes: 13 additions & 1 deletion static/app/views/performance/cache/samplePanel/samplePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Button} from 'sentry/components/button';
import Link from 'sentry/components/links/link';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {trackAnalytics} from 'sentry/utils/analytics';
import {DurationUnit, RateUnit, SizeUnit} from 'sentry/utils/discover/fields';
import {PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
import {decodeScalar} from 'sentry/utils/queryString';
Expand All @@ -34,6 +35,7 @@ import {useTransactions} from 'sentry/views/starfish/queries/useTransactions';
import {
MetricsFields,
type MetricsQueryFilters,
ModuleName,
SpanFunction,
SpanIndexedField,
type SpanIndexedQueryFilters,
Expand Down Expand Up @@ -346,7 +348,17 @@ export function CacheSamplePanel() {

<Fragment>
<ModuleLayout.Full>
<Button onClick={handleRefetch}>{t('Try Different Samples')}</Button>
<Button
onClick={() => {
trackAnalytics(
'performance_views.sample_spans.try_different_samples_clicked',
{organization, source: ModuleName.CACHE}
);
handleRefetch();
}}
>
{t('Try Different Samples')}
</Button>
</ModuleLayout.Full>
</Fragment>
</ModuleLayout.Layout>
Expand Down
16 changes: 15 additions & 1 deletion static/app/views/performance/cache/tables/transactionCell.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as qs from 'query-string';

import Link from 'sentry/components/links/link';
import {trackAnalytics} from 'sentry/utils/analytics';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {useCacheUrl} from 'sentry/views/performance/cache/utils';
import {OverflowEllipsisTextContainer} from 'sentry/views/starfish/components/textAlign';
import {ModuleName} from 'sentry/views/starfish/types';

interface Props {
project?: string;
Expand All @@ -12,6 +15,7 @@ interface Props {
}

export function TransactionCell({project, transaction}: Props) {
const organization = useOrganization();
const location = useLocation();
const cacheUrl = useCacheUrl();

Expand All @@ -27,7 +31,17 @@ export function TransactionCell({project, transaction}: Props) {

return (
<OverflowEllipsisTextContainer>
<Link to={`${cacheUrl}/?${qs.stringify(query)}`}>{transaction}</Link>
<Link
onClick={() =>
trackAnalytics('performance_views.sample_spans.opened', {
organization,
source: ModuleName.CACHE,
})
}
to={`${cacheUrl}/?${qs.stringify(query)}`}
>
{transaction}
</Link>
</OverflowEllipsisTextContainer>
);
}
Expand Down

0 comments on commit ab95284

Please sign in to comment.