Skip to content

fix(replays): add prompt if user needs SDK upgrade #53672

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

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file removed api-docs/dump.rdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ function init({organizationProps = {features: ['session-replay']}}: InitializeOr
describe('GroupReplays', () => {
beforeEach(() => {
MockApiClient.clearMockResponses();
MockApiClient.addMockResponse({
method: 'GET',
url: `/organizations/org-slug/sdk-updates/`,
body: [],
});
});

describe('Replay Feature Disabled', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ describe('TransactionReplays', () => {
let eventsMockApi: jest.Mock<any, any>;
let replaysMockApi: jest.Mock<any, any>;
beforeEach(() => {
MockApiClient.addMockResponse({
method: 'GET',
url: `/organizations/org-slug/sdk-updates/`,
body: [],
});
MockApiClient.addMockResponse({
url: '/organizations/org-slug/events-has-measurements/',
body: {measurements: false},
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/replays/list/replaysList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function ReplaysListTable({
const {needsUpdate: allSelectedProjectsNeedUpdates} = useProjectSdkNeedsUpdate({
minVersion: MIN_REPLAY_CLICK_SDK,
organization,
projectId: projects.map(p => String(p)),
projectId: projects.map(String),
});

const conditions = useMemo(() => {
Expand Down
57 changes: 52 additions & 5 deletions static/app/views/replays/replayTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import styled from '@emotion/styled';
import {Location} from 'history';

import {Alert} from 'sentry/components/alert';
import ExternalLink from 'sentry/components/links/externalLink';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import PanelTable from 'sentry/components/panels/panelTable';
import {t} from 'sentry/locale';
import {t, tct} from 'sentry/locale';
import EventView from 'sentry/utils/discover/eventView';
import type {Sort} from 'sentry/utils/discover/fields';
import getRouteStringFromRoutes from 'sentry/utils/getRouteStringFromRoutes';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import useProjectSdkNeedsUpdate from 'sentry/utils/useProjectSdkNeedsUpdate';
import {useRoutes} from 'sentry/utils/useRoutes';
import type {ReplayListRecordWithTx} from 'sentry/views/performance/transactionSummary/transactionReplays/useReplaysWithTxData';
import HeaderCell from 'sentry/views/replays/replayTable/headerCell';
Expand All @@ -28,6 +31,8 @@ import {
import {ReplayColumn} from 'sentry/views/replays/replayTable/types';
import type {ReplayListRecord} from 'sentry/views/replays/types';

const MIN_DEAD_RAGE_CLICK_SDK = '7.60.1';

type Props = {
fetchError: undefined | Error;
isFetching: boolean;
Expand All @@ -53,6 +58,18 @@ function ReplayTable({
const newLocation = useLocation();
const organization = useOrganization();

const {
selection: {projects},
} = usePageFilters();

const needSDKUpgrade = useProjectSdkNeedsUpdate({
minVersion: MIN_DEAD_RAGE_CLICK_SDK,
organization,
projectId: projects.map(String),
});

const showBottomBorder = visibleColumns.includes(ReplayColumn.MOST_RAGE_CLICKS);

const location: Location = saveLocation
? {
pathname: '',
Expand All @@ -78,7 +95,7 @@ function ReplayTable({
data-test-id="replay-table"
gridRows={undefined}
>
<StyledAlert type="error" showIcon>
<StyledAlert type="error" showIcon showBottomBorder={showBottomBorder}>
{typeof fetchError === 'string'
? fetchError
: t(
Expand All @@ -89,6 +106,32 @@ function ReplayTable({
);
}

if (
needSDKUpgrade.needsUpdate &&
visibleColumns.includes(ReplayColumn.COUNT_DEAD_CLICKS)
) {
return (
<StyledPanelTable
headers={tableHeaders}
visibleColumns={visibleColumns}
data-test-id="replay-table"
gridRows={undefined}
loader={<LoadingIndicator style={{margin: '54px auto'}} />}
disablePadding
>
<StyledAlert type="info" showIcon showBottomBorder={showBottomBorder}>
{tct('[data] requires [sdkPrompt]. [link:Upgrade now.]', {
data: <strong>Rage and dead clicks</strong>,
sdkPrompt: <strong>{t('SDK version >= 7.60.1')}</strong>,
link: (
<ExternalLink href="https://docs.sentry.io/platforms/javascript/install/npm/" />
),
})}
</StyledAlert>
</StyledPanelTable>
);
}

const referrer = getRouteStringFromRoutes(routes);
const eventView = EventView.fromLocation(location);

Expand Down Expand Up @@ -207,14 +250,18 @@ const StyledPanelTable = styled(PanelTable)<{
)
.join(' ')};

${props => (props.gridRows ? `grid-template-rows: ${props.gridRows};` : '')}
${props =>
props.gridRows
? `grid-template-rows: ${props.gridRows};`
: `grid-template-rows: 44px max-content;`}
`;

const StyledAlert = styled(Alert)`
const StyledAlert = styled(Alert)<{showBottomBorder?: boolean}>`
border-radius: 0;
border-width: 1px 0 0 0;
grid-column: 1/-1;
margin-bottom: 0;
${props =>
props.showBottomBorder ? `border-width: 1px 0 1px 0;` : `border-width: 1px 0 0 0;`}
`;

export default ReplayTable;