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:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-sentry': patch
|
||||
---
|
||||
|
||||
feature: sentry-plugin allows passing search query for listing issues
|
||||
@@ -36,7 +36,11 @@ export class MockSentryApi implements SentryApi {
|
||||
export class ProductionSentryApi implements SentryApi {
|
||||
constructor(discoveryApi: DiscoveryApi, organization: string);
|
||||
// (undocumented)
|
||||
fetchIssues(project: string, statsFor: string): Promise<SentryIssue[]>;
|
||||
fetchIssues(
|
||||
project: string,
|
||||
statsFor: string,
|
||||
query: string,
|
||||
): Promise<SentryIssue[]>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
@@ -49,7 +53,11 @@ export const Router: ({ entity }: { entity: Entity }) => JSX.Element;
|
||||
// @public (undocumented)
|
||||
export interface SentryApi {
|
||||
// (undocumented)
|
||||
fetchIssues(project: string, statsFor: string): Promise<SentryIssue[]>;
|
||||
fetchIssues(
|
||||
project: string,
|
||||
statsFor: string,
|
||||
query: string,
|
||||
): Promise<SentryIssue[]>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "sentryApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
@@ -100,10 +108,12 @@ export const SentryIssuesWidget: ({
|
||||
entity,
|
||||
statsFor,
|
||||
variant,
|
||||
query,
|
||||
}: {
|
||||
entity: Entity;
|
||||
statsFor?: '12h' | '24h' | undefined;
|
||||
variant?: InfoCardVariants | undefined;
|
||||
query?: string | undefined;
|
||||
}) => JSX.Element;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "sentryPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
|
||||
@@ -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