Skip to content

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

Chore/custom content logs default query (#38087)

Joshen Limb8b01efae674
diff --git a/apps/studio/hooks/custom-content/CustomContent.types.ts b/apps/studio/hooks/custom-content/CustomContent.types.ts
index 57bfadada57..94634447b3c 100644
--- a/apps/studio/hooks/custom-content/CustomContent.types.ts
+++ b/apps/studio/hooks/custom-content/CustomContent.types.ts
@@ -11,4 +11,6 @@ export type CustomContentTypes = {
iconUrl: string
url: string
}[]
+
+ logsDefaultQuery: string
}
diff --git a/apps/studio/hooks/custom-content/custom-content.json b/apps/studio/hooks/custom-content/custom-content.json
index eb9035fde27..db8c9a471b8 100644
--- a/apps/studio/hooks/custom-content/custom-content.json
+++ b/apps/studio/hooks/custom-content/custom-content.json
@@ -3,5 +3,7 @@
"organization:legal_documents": null,
- "project_homepage:example_projects": null
+ "project_homepage:example_projects": null,
+
+ "logs:default_query": null
}
diff --git a/apps/studio/hooks/custom-content/custom-content.sample.json b/apps/studio/hooks/custom-content/custom-content.sample.json
index b9454c592b4..4fd040f0cc0 100644
--- a/apps/studio/hooks/custom-content/custom-content.sample.json
+++ b/apps/studio/hooks/custom-content/custom-content.sample.json
@@ -35,5 +35,7 @@
"iconUrl": "https://supabase.com/dashboard/img/supabase-logo.svg",
"url": "https://supabase.com"
}
- ]
+ ],
+
+ "logs:default_query": "This is a sample query"
}
diff --git a/apps/studio/hooks/custom-content/custom-content.schema.json b/apps/studio/hooks/custom-content/custom-content.schema.json
index 9d67dae109e..c3e5c5919f8 100644
--- a/apps/studio/hooks/custom-content/custom-content.schema.json
+++ b/apps/studio/hooks/custom-content/custom-content.schema.json
@@ -37,8 +37,17 @@
"url": { "type": "string" }
}
}
+ },
+
+ "logs:default_query": {
+ "type": ["string", "null"],
+ "description": "Renders a default query when landing on the logs explorer"
}
},
- "required": ["organization:legal_documents", "project_homepage:example_projects"],
+ "required": [
+ "organization:legal_documents",
+ "project_homepage:example_projects",
+ "logs:default_query"
+ ],
"additionalProperties": false
}
diff --git a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
index a62ec23c3f1..79f7ff78c29 100644
--- a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
+++ b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
@@ -36,6 +36,7 @@ import {
} from 'data/content/content-upsert-mutation'
import useLogsQuery from 'hooks/analytics/useLogsQuery'
import { useLogsUrlState } from 'hooks/analytics/useLogsUrlState'
+import { useCustomContent } from 'hooks/custom-content/useCustomContent'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useUpgradePrompt } from 'hooks/misc/useUpgradePrompt'
import { uuidv4 } from 'lib/helpers'
@@ -57,8 +58,6 @@ const LOCAL_PLACEHOLDER_QUERY =
const PLATFORM_PLACEHOLDER_QUERY =
'select\n cast(timestamp as datetime) as timestamp,\n event_message, metadata \nfrom edge_logs \nlimit 5'
-const PLACEHOLDER_QUERY = IS_PLATFORM ? PLATFORM_PLACEHOLDER_QUERY : LOCAL_PLACEHOLDER_QUERY
-
export const LogsExplorerPage: NextPageWithLayout = () => {
useEditorHints()
const monaco = useMonaco()
@@ -72,6 +71,11 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
const [editorId] = useState<string>(uuidv4())
const { timestampStart, timestampEnd, setTimeRange } = useLogsUrlState()
+ const { logsDefaultQuery } = useCustomContent(['logs:default_query'])
+ const PLACEHOLDER_QUERY = IS_PLATFORM
+ ? logsDefaultQuery ?? PLATFORM_PLACEHOLDER_QUERY
+ : LOCAL_PLACEHOLDER_QUERY
+
const [editorValue, setEditorValue] = useState<string>(PLACEHOLDER_QUERY)
const [saveModalOpen, setSaveModalOpen] = useState<boolean>(false)
const [warnings, setWarnings] = useState<LogsWarning[]>([])