Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(support form): bug with log snapshot (#39819)

Charis33e716c68439
diff --git a/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsx b/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsx
index 02a97920497..47a5f804dfe 100644
--- a/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsx
+++ b/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsx
@@ -11,14 +11,15 @@ import {
} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import type { SupportFormValues } from './SupportForm.schema'
-import { DASHBOARD_LOG_CATEGORIES, getSanitizedBreadcrumbs } from './dashboard-logs'
+import { DASHBOARD_LOG_CATEGORIES } from './dashboard-logs'
interface DashboardLogsToggleProps {
form: UseFormReturn<SupportFormValues>
+ sanitizedLog: unknown[]
}
-export function DashboardLogsToggle({ form }: DashboardLogsToggleProps) {
- const sanitizedLogJson = useMemo(() => JSON.stringify(getSanitizedBreadcrumbs(), null, 2), [])
+export function DashboardLogsToggle({ form, sanitizedLog }: DashboardLogsToggleProps) {
+ const sanitizedLogJson = useMemo(() => JSON.stringify(sanitizedLog, null, 2), [sanitizedLog])
const [isPreviewOpen, setIsPreviewOpen] = useState(false)
diff --git a/apps/studio/components/interfaces/Support/SupportFormV2.tsx b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
index 398857db16b..0ec5a4efe95 100644
--- a/apps/studio/components/interfaces/Support/SupportFormV2.tsx
+++ b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
@@ -3,7 +3,7 @@ import type { SubmitHandler, UseFormReturn } from 'react-hook-form'
// End of third-party imports
import { SupportCategories } from '@supabase/shared-types/out/constants'
-import { useFlag } from 'common'
+import { useConstant, useFlag } from 'common'
import { CLIENT_LIBRARIES } from 'common/constants'
import { getProjectAuthConfig } from 'data/auth/auth-config-query'
import { useSendSupportTicketMutation } from 'data/feedback/support-ticket-send'
@@ -35,7 +35,11 @@ import {
NO_ORG_MARKER,
NO_PROJECT_MARKER,
} from './SupportForm.utils'
-import { DASHBOARD_LOG_CATEGORIES, uploadDashboardLog } from './dashboard-logs'
+import {
+ DASHBOARD_LOG_CATEGORIES,
+ getSanitizedBreadcrumbs,
+ uploadDashboardLog,
+} from './dashboard-logs'
const useIsSimplifiedForm = (slug: string) => {
const simplifiedSupportForm = useFlag('simplifiedSupportForm')
@@ -69,6 +73,8 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo
const attachmentUpload = useAttachmentUpload()
const { mutateAsync: uploadDashboardLogFn } = useGenerateAttachmentURLsMutation()
+ const sanitizedLogSnapshot = useConstant(getSanitizedBreadcrumbs)
+
const { data: commit } = useDeploymentCommitQuery({
staleTime: 1000 * 60 * 10, // 10 minutes
})
@@ -100,7 +106,11 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo
const [attachments, dashboardLogUrl] = await Promise.all([
attachmentUpload.createAttachments(),
attachDashboardLogs
- ? uploadDashboardLog({ userId: profile?.gotrue_id, uploadDashboardLogFn })
+ ? uploadDashboardLog({
+ userId: profile?.gotrue_id,
+ sanitizedLogs: sanitizedLogSnapshot,
+ uploadDashboardLogFn,
+ })
: undefined,
])
@@ -212,7 +222,7 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo
{DASHBOARD_LOG_CATEGORIES.includes(category) && (
<>
- <DashboardLogsToggle form={form} />
+ <DashboardLogsToggle form={form} sanitizedLog={sanitizedLogSnapshot} />
<DialogSectionSeparator />
</>
)}
diff --git a/apps/studio/components/interfaces/Support/dashboard-logs.ts b/apps/studio/components/interfaces/Support/dashboard-logs.ts
index 93da930b3a8..caa85b87fc4 100644
--- a/apps/studio/components/interfaces/Support/dashboard-logs.ts
+++ b/apps/studio/components/interfaces/Support/dashboard-logs.ts
@@ -26,9 +26,11 @@ export const getSanitizedBreadcrumbs = (): unknown[] => {
export const uploadDashboardLog = async ({
userId,
+ sanitizedLogs,
uploadDashboardLogFn,
}: {
userId: string | undefined
+ sanitizedLogs: unknown[]
uploadDashboardLogFn: (
vars: GenerateAttachmentURLsVariables
) => Promise<GenerateAttachmentURLsData>
@@ -40,13 +42,12 @@ export const uploadDashboardLog = async ({
return []
}
- const sanitized = getSanitizedBreadcrumbs()
- if (sanitized.length === 0) return []
+ if (sanitizedLogs.length === 0) return []
try {
const supportStorageClient = createSupportStorageClient()
const objectKey = `${userId}/${uuidv4()}.json`
- const body = new Blob([JSON.stringify(sanitized, null, 2)], {
+ const body = new Blob([JSON.stringify(sanitizedLogs, null, 2)], {
type: 'application/json',
})