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:
@@ -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) {
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user