Skip to content

Commit 4ad158c

Browse files
authored
feat(replays): Fetch and render less information when session-replay-slim-table is enabled (#46207)
See also new Feature Flag: #46208 Related to getsentry/team-replay#49 **Before:** ![SCR-20230322-f76](https://user-images.githubusercontent.com/187460/226995542-fafba006-e27f-4aaf-b58b-2aef8d9f23f3.png) **After:** ![SCR-20230322-f7l](https://user-images.githubusercontent.com/187460/226995567-3ec6d199-7734-4b4d-babf-53cd2cd3fdcf.png)
1 parent ac0301e commit 4ad158c

File tree

4 files changed

+64
-26
lines changed

4 files changed

+64
-26
lines changed

static/app/utils/replays/fetchReplayList.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,23 @@ async function fetchReplayList({
3434
try {
3535
const path = `/organizations/${organization.slug}/replays/`;
3636

37+
const payload = eventView.getEventsAPIPayload(location);
38+
3739
// HACK!!! Because the sort field needs to be in the eventView, but I cannot
3840
// ask the server for compound fields like `os.name`.
39-
const payload = eventView.getEventsAPIPayload(location);
40-
payload.field = Array.from(new Set(payload.field.map(field => field.split('.')[0])));
41+
payload.field = payload.field.map(field => field.split('.')[0]);
42+
43+
const hasFullTable = !organization.features.includes('session-replay-slim-table');
44+
if (!hasFullTable) {
45+
const fieldsToRemove = ['browser', 'os', 'urls'];
46+
payload.field = payload.field.filter(field => !fieldsToRemove.includes(field));
47+
payload.field.push('count_urls');
48+
} else {
49+
payload.field = payload.field.filter(field => field !== 'count_urls');
50+
}
51+
52+
// unique list
53+
payload.field = Array.from(new Set(payload.field));
4154

4255
const [{data}, _textStatus, resp] = await api.requestPromise(path, {
4356
includeAllArgs: true,

static/app/views/replays/replayTable/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ function ReplayTable({fetchError, isFetching, replays, sort, visibleColumns}: Pr
3737
const location = useLocation();
3838
const organization = useOrganization();
3939

40+
const hasFullTable = !organization.features.includes('session-replay-slim-table');
41+
visibleColumns = visibleColumns.filter(
42+
column => hasFullTable || !['browser', 'os'].includes(column)
43+
);
44+
4045
const tableHeaders = visibleColumns
4146
.filter(Boolean)
4247
.map(column => <HeaderCell key={column} column={column} sort={sort} />);

static/app/views/replays/replayTable/tableCell.tsx

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {StringWalker} from 'sentry/components/replays/walker/urlWalker';
1111
import ScoreBar from 'sentry/components/scoreBar';
1212
import TimeSince from 'sentry/components/timeSince';
1313
import CHART_PALETTE from 'sentry/constants/chartPalette';
14-
import {IconCalendar} from 'sentry/icons';
14+
import {IconCalendar, IconLocation} from 'sentry/icons';
15+
import {tn} from 'sentry/locale';
1516
import {space, ValidSize} from 'sentry/styles/space';
1617
import type {Organization} from 'sentry/types';
1718
import EventView from 'sentry/utils/discover/eventView';
@@ -44,6 +45,39 @@ export function ReplayCell({
4445
},
4546
};
4647

48+
const subText = replay.urls ? (
49+
<Cols>
50+
<StringWalker urls={replay.urls} />
51+
<Row gap={1}>
52+
<Row gap={0.5}>
53+
{project ? <Avatar size={12} project={project} /> : null}
54+
<Link to={replayDetails}>{getShortEventId(replay.id)}</Link>
55+
</Row>
56+
<Row gap={0.5}>
57+
<IconCalendar color="gray300" size="xs" />
58+
<TimeSince date={replay.started_at} />
59+
</Row>
60+
</Row>
61+
</Cols>
62+
) : (
63+
<Cols>
64+
<Row gap={1}>
65+
<Row gap={0.5} minWidth={80}>
66+
{project ? <Avatar size={12} project={project} /> : null}
67+
<Link to={replayDetails}>{getShortEventId(replay.id)}</Link>
68+
</Row>
69+
<Row gap={0.5} minWidth={80}>
70+
<IconLocation color="green400" size="sm" />
71+
{tn('%s Page', '%s Pages', replay.count_urls)}
72+
</Row>
73+
<Row gap={0.5}>
74+
<IconCalendar color="gray300" size="xs" />
75+
<TimeSince date={replay.started_at} />
76+
</Row>
77+
</Row>
78+
</Cols>
79+
);
80+
4781
return (
4882
<Item>
4983
<UserBadgeFullWidth
@@ -59,21 +93,7 @@ export function ReplayCell({
5993
name: replay.user.username || '',
6094
}}
6195
// this is the subheading for the avatar, so displayEmail in this case is a misnomer
62-
displayEmail={
63-
<Cols>
64-
<StringWalker urls={replay.urls} />
65-
<Row gap={1}>
66-
<Row gap={0.5}>
67-
{project ? <Avatar size={12} project={project} /> : null}
68-
<Link to={replayDetails}>{getShortEventId(replay.id)}</Link>
69-
</Row>
70-
<Row gap={0.5}>
71-
<IconCalendar color="gray300" size="xs" />
72-
<TimeSince date={replay.started_at} />
73-
</Row>
74-
</Row>
75-
</Cols>
76-
}
96+
displayEmail={subText}
7797
/>
7898
</Item>
7999
);
@@ -87,14 +107,15 @@ const UserBadgeFullWidth = styled(UserBadge)`
87107
const Cols = styled('div')`
88108
display: flex;
89109
flex-direction: column;
90-
gap: ${space(0.25)};
110+
gap: ${space(0.5)};
91111
width: 100%;
92112
`;
93113

94-
const Row = styled('div')<{gap: ValidSize}>`
114+
const Row = styled('div')<{gap: ValidSize; minWidth?: number}>`
95115
display: flex;
96116
gap: ${p => space(p.gap)};
97117
align-items: center;
118+
${p => (p.minWidth ? `min-width: ${p.minWidth}px;` : '')}
98119
`;
99120

100121
const MainLink = styled(Link)`
@@ -122,7 +143,7 @@ export function TransactionCell({
122143
}
123144

124145
export function OSCell({replay}: Props) {
125-
const {name, version} = replay.os;
146+
const {name, version} = replay.os ?? {};
126147
const theme = useTheme();
127148
const hasRoomForColumns = useMedia(`(min-width: ${theme.breakpoints.large})`);
128149

@@ -137,7 +158,7 @@ export function OSCell({replay}: Props) {
137158
}
138159

139160
export function BrowserCell({replay}: Props) {
140-
const {name, version} = replay.browser;
161+
const {name, version} = replay.browser ?? {};
141162
const theme = useTheme();
142163
const hasRoomForColumns = useMedia(`(min-width: ${theme.breakpoints.large})`);
143164

static/app/views/replays/types.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,23 @@ export type ReplayListLocationQuery = {
105105
export type ReplayListRecord = Pick<
106106
ReplayRecord,
107107
| 'activity'
108-
| 'browser'
109108
| 'count_errors'
110109
| 'duration'
111110
| 'finished_at'
112111
| 'id'
113-
| 'os'
114112
| 'project_id'
115113
| 'started_at'
116-
| 'urls'
117114
| 'user'
118-
>;
115+
> &
116+
Partial<Pick<ReplayRecord, 'browser' | 'count_urls' | 'os' | 'urls'>>;
119117

120118
// Sync with ReplayListRecord above
121119
export const REPLAY_LIST_FIELDS: ReplayRecordNestedFieldName[] = [
122120
'activity',
123121
'browser.name',
124122
'browser.version',
125123
'count_errors',
124+
'count_urls',
126125
'duration',
127126
'finished_at',
128127
'id',

0 commit comments

Comments
 (0)