|
@@ -1,4 +1,5 @@
|
|
|
import type {Client} from 'sentry/api';
|
|
|
+import type {OrganizationSummary} from 'sentry/types';
|
|
|
import {ApiQueryKey, useApiQuery, UseApiQueryOptions} from 'sentry/utils/queryClient';
|
|
|
|
|
|
type PromptsUpdateParams = {
|
|
@@ -6,11 +7,11 @@ type PromptsUpdateParams = {
|
|
|
* The prompt feature name
|
|
|
*/
|
|
|
feature: string;
|
|
|
- /**
|
|
|
- * The numeric organization ID as a string
|
|
|
- */
|
|
|
- organizationId: string;
|
|
|
status: 'snoozed' | 'dismissed';
|
|
|
+ // TODO(mark) Remove optional once getsentry is updated.
|
|
|
+ organization?: OrganizationSummary;
|
|
|
+ // Deprecated.
|
|
|
+ organizationId?: string;
|
|
|
/**
|
|
|
* The numeric project ID as a string
|
|
|
*/
|
|
@@ -21,10 +22,16 @@ type PromptsUpdateParams = {
|
|
|
* Update the status of a prompt
|
|
|
*/
|
|
|
export function promptsUpdate(api: Client, params: PromptsUpdateParams) {
|
|
|
- return api.requestPromise('/prompts-activity/', {
|
|
|
+ const organizationId = params.organization
|
|
|
+ ? params.organization.id
|
|
|
+ : params.organizationId;
|
|
|
+ const url = params.organization
|
|
|
+ ? `/organizations/${params.organization.slug}/prompts-activity/`
|
|
|
+ : '/prompts-activity/';
|
|
|
+ return api.requestPromise(url, {
|
|
|
method: 'PUT',
|
|
|
data: {
|
|
|
- organization_id: params.organizationId,
|
|
|
+ organization_id: organizationId,
|
|
|
project_id: params.projectId,
|
|
|
feature: params.feature,
|
|
|
status: params.status,
|
|
@@ -37,10 +44,10 @@ type PromptCheckParams = {
|
|
|
* The prompt feature name
|
|
|
*/
|
|
|
feature: string;
|
|
|
- /**
|
|
|
- * The numeric organization ID as a string
|
|
|
- */
|
|
|
- organizationId: string;
|
|
|
+ // TODO(mark) Remove optional once getsentry change has landed.
|
|
|
+ organization?: OrganizationSummary;
|
|
|
+ // Deprecated To be removed once all usage has organization
|
|
|
+ organizationId?: string;
|
|
|
/**
|
|
|
* The numeric project ID as a string
|
|
|
*/
|
|
@@ -68,13 +75,19 @@ export async function promptsCheck(
|
|
|
api: Client,
|
|
|
params: PromptCheckParams
|
|
|
): Promise<PromptData> {
|
|
|
+ const organizationId = params.organization
|
|
|
+ ? params.organization.id
|
|
|
+ : params.organizationId;
|
|
|
const query = {
|
|
|
feature: params.feature,
|
|
|
- organization_id: params.organizationId,
|
|
|
+ organization_id: organizationId,
|
|
|
...(params.projectId === undefined ? {} : {project_id: params.projectId}),
|
|
|
};
|
|
|
+ const url = params.organization
|
|
|
+ ? `/organizations/${params.organization.slug}/prompts-activity/`
|
|
|
+ : '/prompts-activity/';
|
|
|
|
|
|
- const response: PromptResponse = await api.requestPromise('/prompts-activity/', {
|
|
|
+ const response: PromptResponse = await api.requestPromise(url, {
|
|
|
query,
|
|
|
});
|
|
|
|
|
@@ -90,22 +103,27 @@ export async function promptsCheck(
|
|
|
|
|
|
export const makePromptsCheckQueryKey = ({
|
|
|
feature,
|
|
|
+ organization,
|
|
|
organizationId,
|
|
|
projectId,
|
|
|
-}: PromptCheckParams): ApiQueryKey => [
|
|
|
- '/prompts-activity/',
|
|
|
- {query: {feature, organization_id: organizationId, project_id: projectId}},
|
|
|
-];
|
|
|
+}: PromptCheckParams): ApiQueryKey => {
|
|
|
+ const orgId = organization ? organization.id : organizationId;
|
|
|
+ const url = organization
|
|
|
+ ? `/organizations/${organization.slug}/prompts-activity/`
|
|
|
+ : '/prompts-activity/';
|
|
|
+
|
|
|
+ return [url, {query: {feature, organization_id: orgId, project_id: projectId}}];
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
* @param organizationId org numerical id, not the slug
|
|
|
*/
|
|
|
export function usePromptsCheck(
|
|
|
- {feature, organizationId, projectId}: PromptCheckParams,
|
|
|
+ {feature, organization, organizationId, projectId}: PromptCheckParams,
|
|
|
options: Partial<UseApiQueryOptions<PromptResponse>> = {}
|
|
|
) {
|
|
|
return useApiQuery<PromptResponse>(
|
|
|
- makePromptsCheckQueryKey({feature, organizationId, projectId}),
|
|
|
+ makePromptsCheckQueryKey({feature, organization, organizationId, projectId}),
|
|
|
{
|
|
|
staleTime: 120000,
|
|
|
...options,
|
|
@@ -119,15 +137,23 @@ export function usePromptsCheck(
|
|
|
export async function batchedPromptsCheck<T extends readonly string[]>(
|
|
|
api: Client,
|
|
|
features: T,
|
|
|
- params: {organizationId: string; projectId?: string}
|
|
|
+ params: {
|
|
|
+ organization?: OrganizationSummary;
|
|
|
+ organizationId?: string;
|
|
|
+ projectId?: string;
|
|
|
+ }
|
|
|
): Promise<{[key in T[number]]: PromptData}> {
|
|
|
+ const orgId = params.organization ? params.organization.id : params.organizationId;
|
|
|
const query = {
|
|
|
feature: features,
|
|
|
- organization_id: params.organizationId,
|
|
|
+ organization_id: orgId,
|
|
|
...(params.projectId === undefined ? {} : {project_id: params.projectId}),
|
|
|
};
|
|
|
+ const url = params.organization
|
|
|
+ ? `/organizations/${params.organization.slug}/prompts-activity/`
|
|
|
+ : '/prompts-activity/';
|
|
|
|
|
|
- const response: PromptResponse = await api.requestPromise('/prompts-activity/', {
|
|
|
+ const response: PromptResponse = await api.requestPromise(url, {
|
|
|
query,
|
|
|
});
|
|
|
const responseFeatures = response?.features;
|