Skip to content

Commit ad93a40

Browse files
authored
ref(explorer): support start/end in nav links (#104490)
requires getsentry/seer#4197 [AIML-1989: Support abs time sentry data queries](https://linear.app/getsentry/issue/AIML-1989/support-abs-time-sentry-data-queries)
1 parent 071dee7 commit ad93a40

File tree

1 file changed

+33
-86
lines changed

1 file changed

+33
-86
lines changed

static/app/views/seerExplorer/utils.tsx

Lines changed: 33 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -403,97 +403,65 @@ export function buildToolLinkUrl(
403403
): LocationDescriptor | null {
404404
switch (toolLink.kind) {
405405
case 'telemetry_live_search': {
406-
const {dataset, query, stats_period, project_slugs, sort} = toolLink.params;
407-
408-
if (dataset === 'issues') {
409-
// Build URL for issues search
410-
const queryParams: Record<string, any> = {
411-
query: query || '',
412-
};
413-
414-
// If project_slugs is provided, look up the project IDs
415-
if (project_slugs && project_slugs.length > 0 && projects) {
416-
const projectIds = project_slugs
417-
.map((slug: string) => projects.find(p => p.slug === slug)?.id)
418-
.filter((id: string | undefined) => id !== undefined);
419-
if (projectIds.length > 0) {
420-
queryParams.project = projectIds;
421-
}
422-
}
406+
const {dataset, project_slugs, query, sort, stats_period, start, end} =
407+
toolLink.params;
423408

424-
if (stats_period) {
425-
queryParams.statsPeriod = stats_period;
426-
}
409+
const queryParams: Record<string, any> = {
410+
query: query || '',
411+
project: null,
412+
};
413+
if (stats_period) {
414+
queryParams.statsPeriod = stats_period;
415+
}
416+
if (sort) {
417+
queryParams.sort = sort;
418+
}
419+
if (start) {
420+
queryParams.start = start;
421+
}
422+
if (end) {
423+
queryParams.end = end;
424+
}
427425

428-
if (sort) {
429-
queryParams.sort = sort;
426+
// If project_slugs is provided, look up the IDs and include them in qparams
427+
if (project_slugs && project_slugs.length > 0 && projects) {
428+
const projectIds = project_slugs
429+
.map((slug: string) => projects.find(p => p.slug === slug)?.id)
430+
.filter((id: string | undefined) => id !== undefined);
431+
if (projectIds.length > 0) {
432+
queryParams.project = projectIds;
430433
}
434+
}
431435

436+
if (dataset === 'issues') {
432437
return {
433438
pathname: `/organizations/${orgSlug}/issues/`,
434439
query: queryParams,
435440
};
436441
}
437442

438443
if (dataset === 'errors') {
439-
const queryParams: Record<string, any> = {
440-
dataset: 'errors',
441-
queryDataset: 'error-events',
442-
query: query || '',
443-
project: null,
444-
};
445-
446-
if (stats_period) {
447-
queryParams.statsPeriod = stats_period;
448-
}
449-
450-
// If project_slugs is provided, look up the project IDs
451-
if (project_slugs && project_slugs.length > 0 && projects) {
452-
const projectIds = project_slugs
453-
.map((slug: string) => projects.find(p => p.slug === slug)?.id)
454-
.filter((id: string | undefined) => id !== undefined);
455-
if (projectIds.length > 0) {
456-
queryParams.project = projectIds;
457-
}
458-
}
444+
queryParams.dataset = 'errors';
445+
queryParams.queryDataset = 'error-events';
459446

460447
const {y_axes} = toolLink.params;
461448
if (y_axes) {
462449
queryParams.yAxis = y_axes;
463450
}
464451

465-
if (sort) {
466-
queryParams.sort = sort;
467-
}
468-
469452
return {
470453
pathname: `/organizations/${orgSlug}/explore/discover/homepage/`,
471454
query: queryParams,
472455
};
473456
}
474457

475458
if (dataset === 'logs') {
476-
const queryParams: Record<string, any> = {
477-
[LOGS_QUERY_KEY]: query || '',
478-
project: null,
479-
};
480-
481-
if (stats_period) {
482-
queryParams.statsPeriod = stats_period;
483-
}
484-
485-
// If project_slugs is provided, look up the project IDs
486-
if (project_slugs && project_slugs.length > 0 && projects) {
487-
const projectIds = project_slugs
488-
.map((slug: string) => projects.find(p => p.slug === slug)?.id)
489-
.filter((id: string | undefined) => id !== undefined);
490-
if (projectIds.length > 0) {
491-
queryParams.project = projectIds;
492-
}
493-
}
459+
queryParams[LOGS_QUERY_KEY] = query || '';
460+
delete queryParams.query;
494461

495462
if (sort) {
496463
queryParams[LOGS_SORT_BYS_KEY] = sort;
464+
delete queryParams.sort;
497465
}
498466

499467
return {
@@ -504,26 +472,8 @@ export function buildToolLinkUrl(
504472

505473
// Default to spans (traces) search
506474
const {y_axes, group_by, mode} = toolLink.params;
507-
508-
const queryParams: Record<string, any> = {
509-
query: query || '',
510-
project: null,
511-
};
512-
513-
// If project_slugs is provided, look up the project IDs
514-
if (project_slugs && project_slugs.length > 0 && projects) {
515-
const projectIds = project_slugs
516-
.map((slug: string) => projects.find(p => p.slug === slug)?.id)
517-
.filter((id: string | undefined) => id !== undefined);
518-
if (projectIds.length > 0) {
519-
queryParams.project = projectIds;
520-
}
521-
}
522-
523475
const aggregateFields: any[] = [];
524-
if (stats_period) {
525-
queryParams.statsPeriod = stats_period;
526-
}
476+
527477
if (y_axes) {
528478
const axes = Array.isArray(y_axes) ? y_axes : [y_axes];
529479
const stringifiedAxes = axes.map(axis => JSON.stringify(axis));
@@ -536,9 +486,6 @@ export function buildToolLinkUrl(
536486
queryParams.groupBy = groupByValue;
537487
aggregateFields.push(JSON.stringify({groupBy: groupByValue}));
538488
}
539-
if (sort) {
540-
queryParams.sort = sort;
541-
}
542489
if (mode) {
543490
queryParams.mode = mode === 'aggregates' ? 'aggregate' : 'samples';
544491
}

0 commit comments

Comments
 (0)