fix: sentry plugin allows search query parameter

specified by documentation https://docs.sentry.io/api/events/list-a-projects-issues/

Signed-off-by: rodion <rodiongork@github.com>
This commit is contained in:
rodion
2021-10-21 21:39:47 +03:00
parent 017a47e585
commit 97231f5581
5 changed files with 34 additions and 7 deletions
+8 -2
View File
@@ -24,15 +24,21 @@ export class ProductionSentryApi implements SentryApi {
private readonly organization: string,
) {}
async fetchIssues(project: string, statsFor: string): Promise<SentryIssue[]> {
async fetchIssues(
project: string,
statsFor: string,
query: string,
): Promise<SentryIssue[]> {
if (!project) {
return [];
}
const apiUrl = `${await this.discoveryApi.getBaseUrl('proxy')}/sentry/api`;
const queryPart = query ? `&query=${query}` : '';
const response = await fetch(
`${apiUrl}/0/projects/${this.organization}/${project}/issues/?statsPeriod=${statsFor}`,
`${apiUrl}/0/projects/${this.organization}/${project}/issues/?statsPeriod=${statsFor}${queryPart}`,
);
if (response.status >= 400 && response.status < 600) {
+5 -1
View File
@@ -23,5 +23,9 @@ export const sentryApiRef = createApiRef<SentryApi>({
});
export interface SentryApi {
fetchIssues(project: string, statsFor: string): Promise<SentryIssue[]>;
fetchIssues(
project: string,
statsFor: string,
query: string,
): Promise<SentryIssue[]>;
}
@@ -38,10 +38,12 @@ export const SentryIssuesWidget = ({
entity,
statsFor = '24h',
variant = 'gridItem',
query = '',
}: {
entity: Entity;
statsFor?: '24h' | '12h';
variant?: InfoCardVariants;
query?: string;
}) => {
const errorApi = useApi<ErrorApi>(errorApiRef);
const sentryApi = useApi(sentryApiRef);
@@ -49,8 +51,8 @@ export const SentryIssuesWidget = ({
const projectId = useProjectSlug(entity);
const { loading, value, error } = useAsync(
() => sentryApi.fetchIssues(projectId, statsFor),
[sentryApi, statsFor, projectId],
() => sentryApi.fetchIssues(projectId, statsFor, query),
[sentryApi, statsFor, projectId, query],
);
useEffect(() => {