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

fix(trace_timeline): Support for trace timeline and related issues (team/free plans) #72933

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ jest.mock('sentry/utils/routeAnalytics/useRouteAnalyticsParams');
jest.mock('sentry/utils/analytics');

describe('TraceTimeline', () => {
const organization = OrganizationFixture();
// Paid plans have global-views enabled
// Include project: -1 in all matchQuery calls to ensure we are looking at all projects
const organization = OrganizationFixture({
features: ['global-views'],
});
// This creates the ApiException event
const event = EventFixture({
dateCreated: '2024-01-24T09:09:03+00:00',
Expand Down Expand Up @@ -72,12 +76,12 @@ describe('TraceTimeline', () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: issuePlatformBody,
match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
match: [MockApiClient.matchQuery({dataset: 'issuePlatform', project: -1})],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: discoverBody,
match: [MockApiClient.matchQuery({dataset: 'discover'})],
match: [MockApiClient.matchQuery({dataset: 'discover', project: -1})],
});
render(<TraceTimeline event={event} />, {organization});
expect(await screen.findByLabelText('Current Event')).toBeInTheDocument();
Expand All @@ -94,12 +98,12 @@ describe('TraceTimeline', () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
match: [MockApiClient.matchQuery({dataset: 'issuePlatform', project: -1})],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: discoverBody,
match: [MockApiClient.matchQuery({dataset: 'discover'})],
match: [MockApiClient.matchQuery({dataset: 'discover', project: -1})],
});
const {container} = render(<TraceTimeline event={event} />, {organization});
await waitFor(() =>
Expand All @@ -115,12 +119,12 @@ describe('TraceTimeline', () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
match: [MockApiClient.matchQuery({dataset: 'issuePlatform', project: -1})],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [MockApiClient.matchQuery({dataset: 'discover'})],
match: [MockApiClient.matchQuery({dataset: 'discover', project: -1})],
});
const {container} = render(<TraceTimeline event={event} />, {organization});
await waitFor(() =>
Expand All @@ -136,12 +140,12 @@ describe('TraceTimeline', () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: issuePlatformBody,
match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
match: [MockApiClient.matchQuery({dataset: 'issuePlatform', project: -1})],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [MockApiClient.matchQuery({dataset: 'discover'})],
match: [MockApiClient.matchQuery({dataset: 'discover', project: -1})],
});
render(<TraceTimeline event={event} />, {organization});
// Checking for the presence of seconds
Expand All @@ -152,12 +156,12 @@ describe('TraceTimeline', () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: issuePlatformBody,
match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
match: [MockApiClient.matchQuery({dataset: 'issuePlatform', project: -1})],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [MockApiClient.matchQuery({dataset: 'discover'})],
match: [MockApiClient.matchQuery({dataset: 'discover', project: -1})],
});
render(<TraceTimeline event={event} />, {organization});
expect(await screen.findByLabelText('Current Event')).toBeInTheDocument();
Expand All @@ -167,12 +171,12 @@ describe('TraceTimeline', () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: issuePlatformBody,
match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
match: [MockApiClient.matchQuery({dataset: 'issuePlatform', project: -1})],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [MockApiClient.matchQuery({dataset: 'discover'})],
match: [MockApiClient.matchQuery({dataset: 'discover', project: -1})],
});
// I believe the call to projects is to determine what projects a user belongs to
MockApiClient.addMockResponse({
Expand All @@ -182,7 +186,7 @@ describe('TraceTimeline', () => {

render(<TraceTimeline event={event} />, {
organization: OrganizationFixture({
features: ['related-issues-issue-details-page'],
features: ['related-issues-issue-details-page', 'global-views'],
}),
});

Expand All @@ -201,7 +205,7 @@ describe('TraceTimeline', () => {
{
group_id: issuePlatformBody.data[0]['issue.id'],
organization: OrganizationFixture({
features: ['related-issues-issue-details-page'],
features: ['related-issues-issue-details-page', 'global-views'],
}),
}
);
Expand All @@ -211,13 +215,13 @@ describe('TraceTimeline', () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
match: [MockApiClient.matchQuery({dataset: 'issuePlatform', project: -1})],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
// Only 1 issue
body: discoverBody,
match: [MockApiClient.matchQuery({dataset: 'discover'})],
match: [MockApiClient.matchQuery({dataset: 'discover', project: -1})],
});
// I believe the call to projects is to determine what projects a user belongs to
MockApiClient.addMockResponse({
Expand All @@ -227,7 +231,7 @@ describe('TraceTimeline', () => {

render(<TraceTimeline event={event} />, {
organization: OrganizationFixture({
features: ['related-issues-issue-details-page'],
features: ['related-issues-issue-details-page', 'global-views'],
}),
});

Expand All @@ -244,4 +248,36 @@ describe('TraceTimeline', () => {
trace_timeline_status: 'empty',
});
});

it('works for free plans (no global-views feature)', async () => {
armenzg marked this conversation as resolved.
Show resolved Hide resolved
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: issuePlatformBody,
match: [
MockApiClient.matchQuery({
dataset: 'issuePlatform',
// Since we don't have global-views, we only look at the current project
project: event.projectID,
}),
],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: emptyBody,
match: [
MockApiClient.matchQuery({
dataset: 'discover',
// Since we don't have global-views, we only look at the current project
project: event.projectID,
}),
],
});

render(<TraceTimeline event={event} />, {
organization: OrganizationFixture({
features: [], // No global-views feature
}),
});
expect(await screen.findByLabelText('Current Event')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export function useTraceTimelineEvents({event}: UseTraceTimelineEventsOptions):
traceEvents: TimelineEvent[];
} {
const organization = useOrganization();
// If the org has global views, we want to look across all projects,
// otherwise, just look at the current project.
const hasGlobalViews = organization.features.includes('global-views');
const project = hasGlobalViews ? -1 : event.projectID;
const {start, end} = getTraceTimeRangeFromEvent(event);

const traceId = event.contexts?.trace?.trace_id ?? '';
Expand All @@ -65,6 +69,7 @@ export function useTraceTimelineEvents({event}: UseTraceTimelineEventsOptions):
sort: '-timestamp',
start,
end,
project: project,
},
},
],
Expand Down Expand Up @@ -100,6 +105,7 @@ export function useTraceTimelineEvents({event}: UseTraceTimelineEventsOptions):
sort: '-timestamp',
start,
end,
project: project,
},
},
],
Expand Down
Loading