Skip to content

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

Joshenlim/fe 4676 port log drains api endpoints from platform to v2 (#51995)

Joshen Lim3af897e6d61f
diff --git a/apps/studio/.github/eslint-rule-baselines.json b/apps/studio/.github/eslint-rule-baselines.json
index 13924b930e7..da00afcbf04 100644
--- a/apps/studio/.github/eslint-rule-baselines.json
+++ b/apps/studio/.github/eslint-rule-baselines.json
@@ -162,8 +162,8 @@
"pages/api/platform/pg-meta/[ref]/views.ts": 1,
"pages/api/platform/profile/index.ts": 1,
"pages/api/platform/projects/[ref]/analytics/endpoints/[name].ts": 1,
- "pages/api/platform/projects/[ref]/analytics/log-drains.ts": 1,
- "pages/api/platform/projects/[ref]/analytics/log-drains/[uuid].ts": 1,
+ "pages/api/v2/projects/[ref]/analytics/log-drains.ts": 1,
+ "pages/api/v2/projects/[ref]/analytics/log-drains/[id].ts": 1,
"pages/api/platform/projects/[ref]/api-keys/temporary.ts": 1,
"pages/api/platform/projects/[ref]/api/graphql.ts": 1,
"pages/api/platform/projects/[ref]/api/rest.ts": 1,
@@ -602,7 +602,7 @@
"pages/api/platform/auth/[ref]/users/[id]/factors.ts": 1,
"pages/api/platform/database/[ref]/pooling.ts": 1,
"pages/api/platform/integrations/github/authorization.ts": 1,
- "pages/api/platform/projects/[ref]/analytics/log-drains.ts": 1,
+ "pages/api/v2/projects/[ref]/analytics/log-drains.ts": 1,
"pages/api/platform/projects/[ref]/content/count.ts": 1,
"pages/api/platform/projects/[ref]/content/index.ts": 1,
"pages/api/platform/projects/[ref]/databases.ts": 1,
diff --git a/apps/studio/components/interfaces/LogDrains/LogDrainsList.tsx b/apps/studio/components/interfaces/LogDrains/LogDrainsList.tsx
index 77a81147a93..13329d7ce48 100644
--- a/apps/studio/components/interfaces/LogDrains/LogDrainsList.tsx
+++ b/apps/studio/components/interfaces/LogDrains/LogDrainsList.tsx
@@ -1,13 +1,13 @@
import { IS_PLATFORM } from 'common'
-import { MoreHorizontalIcon, PlugZapIcon, TrashIcon } from 'lucide-react'
+import { MoreVerticalIcon, PlugZapIcon, TrashIcon } from 'lucide-react'
import { cloneElement, useEffect, useRef, useState } from 'react'
import {
- Button,
Card,
cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
+ DropdownMenuSeparator,
DropdownMenuTrigger,
Table,
TableBody,
@@ -24,6 +24,7 @@ import { LogDrainsCard } from './LogDrainsCard'
import { useEnabledLogDrainTypes } from './useEnabledLogDrainTypes'
import { VoteLink } from './VoteLink'
import { AlertError } from '@/components/ui/AlertError'
+import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { LogDrainData } from '@/data/log-drains/log-drains-query'
import type { ResponseError } from '@/types'
@@ -112,7 +113,7 @@ export function LogDrainsList({
<TableBody>
{logDrains
?.slice()
- .sort((a, b) => b.id - a.id)
+ .sort((a, b) => a.name.localeCompare(b.name))
.map((drain) => (
<TableRow key={drain.id}>
<TableCell className="font-medium truncate max-w-72" title={drain.name}>
@@ -145,27 +146,35 @@ export function LogDrainsList({
<TableCell className="text-right">
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
- variant="text"
+ <ButtonTooltip
+ variant="default"
className="px-1 opacity-50 hover:opacity-100 bg-transparent! shrink-0"
- icon={<MoreHorizontalIcon />}
+ icon={<MoreVerticalIcon />}
+ tooltip={{ content: { side: 'bottom', text: 'More options' } }}
/>
</DropdownMenuTrigger>
<DropdownMenuContent className="max-w-[160px]" align="end">
{onTestDrain && (
- <DropdownMenuItem onClick={() => onTestDrain(drain)}>
- <PlugZapIcon className="h-4 w-4 mr-2" />
- Test connection
- </DropdownMenuItem>
+ <>
+ <DropdownMenuItem
+ className="gap-x-2"
+ onClick={() => onTestDrain(drain)}
+ >
+ <PlugZapIcon size={14} />
+ Test connection
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ </>
)}
<DropdownMenuItem
+ className="gap-x-2"
onClick={() => {
setSelectedLogDrain(drain)
setIsDeleteModalOpen(true)
}}
>
- <TrashIcon className="h-4 w-4 mr-2" />
- Delete
+ <TrashIcon size={14} />
+ Delete log drain
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/apps/studio/data/log-drains/audit-log-drains-query.ts b/apps/studio/data/log-drains/audit-log-drains-query.ts
index 9e65a789cde..8f59002deed 100644
--- a/apps/studio/data/log-drains/audit-log-drains-query.ts
+++ b/apps/studio/data/log-drains/audit-log-drains-query.ts
@@ -22,7 +22,10 @@ export async function getAuditLogDrains({ slug }: AuditLogDrainsVariables, signa
if (error) handleError(error)
- return (data ?? []) as LogDrainData[]
+ // Match the flattened shape of project log drains, where `id` is the token
+ return (data ?? []).map(({ token, name, description, config, type }): LogDrainData => {
+ return { id: token, token, name, description, config, type }
+ })
}
export type AuditLogDrainsData = LogDrainData[]
diff --git a/apps/studio/data/log-drains/create-log-drain-mutation.ts b/apps/studio/data/log-drains/create-log-drain-mutation.ts
index 7739690b403..8989b3b26a9 100644
--- a/apps/studio/data/log-drains/create-log-drain-mutation.ts
+++ b/apps/studio/data/log-drains/create-log-drain-mutation.ts
@@ -1,27 +1,35 @@
import { useMutation, useQueryClient } from '@tanstack/react-query'
+import type { components } from 'api-types'
import { toast } from 'sonner'
import { logDrainsKeys } from './keys'
-import { LogDrainType } from '@/components/interfaces/LogDrains/LogDrains.constants'
import { handleError, post } from '@/data/fetchers'
import type { ResponseError, UseCustomMutationOptions } from '@/types'
+type LogDrainAttributes =
+ components['schemas']['CreateLogDrainRequestOpenApi']['data']['attributes']
+
export type LogDrainCreateVariables = {
projectRef: string
name: string
description: string
- config: Record<string, never>
- type: LogDrainType
+ config: LogDrainAttributes['config']
+ type: LogDrainAttributes['backend_type']
}
export async function createLogDrain(payload: LogDrainCreateVariables) {
- const { data, error } = await post('/platform/projects/{ref}/analytics/log-drains', {
+ const { data, error } = await post('/v2/projects/{ref}/analytics/log-drains', {
params: { path: { ref: payload.projectRef } },
body: {
- name: payload.name,
- description: payload.description,
- type: payload.type,
- config: payload.config as any,
+ data: {
+ type: 'log_drain',
+ attributes: {
+ name: payload.name,
+ description: payload.description,
+ backend_type: payload.type,
+ config: payload.config,
+ },
+ },
},
})
diff --git a/apps/studio/data/log-drains/delete-log-drain-mutation.ts b/apps/studio/data/log-drains/delete-log-drain-mutation.ts
index 1c42323deef..5ee7f6d2343 100644
--- a/apps/studio/data/log-drains/delete-log-drain-mutation.ts
+++ b/apps/studio/data/log-drains/delete-log-drain-mutation.ts
@@ -11,9 +11,8 @@ export type LogDrainDeleteVariables = {
}
export async function deleteLogDrain({ projectRef, token }: LogDrainDeleteVariables) {
- // @ts-ignore Just sample, TS lint will validate if the endpoint is valid
- const { data, error } = await del('/platform/projects/{ref}/analytics/log-drains/{token}', {
- params: { path: { ref: projectRef, token } },
+ const { data, error } = await del('/v2/projects/{ref}/analytics/log-drains/{id}', {
+ params: { path: { ref: projectRef, id: token } },
})
if (error) handleError(error)
diff --git a/apps/studio/data/log-drains/log-drains-query.ts b/apps/studio/data/log-drains/log-drains-query.ts
index efdc5644960..16db939061b 100644
--- a/apps/studio/data/log-drains/log-drains-query.ts
+++ b/apps/studio/data/log-drains/log-drains-query.ts
@@ -14,16 +14,18 @@ export async function getLogDrains({ ref }: LogDrainsVariables, signal?: AbortSi
throw new Error('ref is required')
}
- const { data, error } = await get(`/platform/projects/{ref}/analytics/log-drains`, {
+ const { data, error } = await get(`/v2/projects/{ref}/analytics/log-drains`, {
params: { path: { ref: ref } },
signal,
})
- if (error) {
- handleError(error)
- }
+ if (error) handleError(error)
- return data
+ // [Joshen] Format V2 API response to suit the shape which Studio consumes
+ return (data?.data ?? []).map(({ id, attributes }) => {
+ const { name, description, config, backend_type } = attributes
+ return { id, token: id, name, description, config, type: backend_type }
+ })
}
export type LogDrainsData = Awaited<ReturnType<typeof getLogDrains>>
diff --git a/apps/studio/data/log-drains/update-log-drain-mutation.ts b/apps/studio/data/log-drains/update-log-drain-mutation.ts
index 3a8429eb8c9..d689b80bd33 100644
--- a/apps/studio/data/log-drains/update-log-drain-mutation.ts
+++ b/apps/studio/data/log-drains/update-log-drain-mutation.ts
@@ -1,18 +1,21 @@
import { useMutation, useQueryClient } from '@tanstack/react-query'
+import type { components } from 'api-types'
import { toast } from 'sonner'
import { logDrainsKeys } from './keys'
-import { LogDrainType } from '@/components/interfaces/LogDrains/LogDrains.constants'
import { handleError, put } from '@/data/fetchers'
import type { ResponseError, UseCustomMutationOptions } from '@/types'
+type LogDrainAttributes =
+ components['schemas']['UpdateLogDrainRequestOpenApi']['data']['attributes']
+
export type LogDrainUpdateVariables = {
projectRef: string
token?: string
name: string
description?: string
- type: LogDrainType
- config: Record<string, never>
+ type: LogDrainAttributes['backend_type']
+ config: LogDrainAttributes['config']
}
export async function updateLogDrain(payload: LogDrainUpdateVariables) {
@@ -20,13 +23,18 @@ export async function updateLogDrain(payload: LogDrainUpdateVariables) {
throw new Error('Token is required')
}
- const { data, error } = await put('/platform/projects/{ref}/analytics/log-drains/{token}', {
- params: { path: { ref: payload.projectRef, token: payload.token } },
+ const { data, error } = await put('/v2/projects/{ref}/analytics/log-drains/{id}', {
+ params: { path: { ref: payload.projectRef, id: payload.token } },
body: {
- name: payload.name,
- description: payload.description,
- type: payload.type,
- config: payload.config as any,
+ data: {
+ type: 'log_drain',
+ attributes: {
+ name: payload.name,
+ description: payload.description,
+ backend_type: payload.type,
+ config: payload.config,
+ },
+ },
},
})
diff --git a/apps/studio/data/profile/profile-query.ts b/apps/studio/data/profile/profile-query.ts
index 122ce394d3c..a92debbfa7c 100644
--- a/apps/studio/data/profile/profile-query.ts
+++ b/apps/studio/data/profile/profile-query.ts
@@ -1,7 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import { profileKeys } from './keys'
-import type { Profile } from './types'
import { get, handleError } from '@/data/fetchers'
import { IS_PLATFORM } from '@/lib/constants'
import type { ResponseError, UseCustomQueryOptions } from '@/types'
@@ -18,9 +17,9 @@ export async function getProfile(signal?: AbortSignal) {
return {
...data,
disabled_features: process.env.NEXT_PUBLIC_DISABLED_FEATURES?.split(',') ?? [],
- } as Profile
+ }
} else {
- return data as Profile
+ return data
}
}
diff --git a/apps/studio/lib/api/self-hosted/log-drains.test.ts b/apps/studio/lib/api/self-hosted/log-drains.test.ts
new file mode 100644
index 00000000000..9a57e41de7a
--- /dev/null
+++ b/apps/studio/lib/api/self-hosted/log-drains.test.ts
@@ -0,0 +1,58 @@
+import { describe, expect, it } from 'vitest'
+
+import { asLogDrainResource, parseLogDrainRequest } from './log-drains'
+
+describe('parseLogDrainRequest', () => {
+ it('flattens a v2 request body into a Logflare backend payload', () => {
+ const result = parseLogDrainRequest({
+ data: {
+ type: 'log_drain',
+ attributes: {
+ name: 'My drain',
+ description: 'desc',
+ backend_type: 'webhook',
+ config: { url: 'https://example.com' },
+ },
+ },
+ })
+
+ expect(result).toEqual({
+ success: true,
+ data: {
+ name: 'My drain',
+ description: 'desc',
+ type: 'webhook',
+ config: { url: 'https://example.com' },
+ },
+ })
+ })
+
+ it('rejects a body that is not wrapped in data.attributes', () => {
+ const result = parseLogDrainRequest({ name: 'My drain', type: 'webhook', config: {} })
+
+ expect(result.success).toBe(false)
+ })
+})
+
+describe('asLogDrainResource', () => {
+ it('uses the Logflare token as the id and renames type to backend_type', () => {
+ expect(
+ asLogDrainResource({
+ token: 'tok-1',
+ name: 'My drain',
+ description: 'desc',
+ type: 'datadog',
+ config: { api_key: 'key' },
+ })
+ ).toEqual({
+ type: 'log_drain',
+ id: 'tok-1',
+ attributes: {
+ name: 'My drain',
+ description: 'desc',
+ config: { api_key: 'key' },
+ backend_type: 'datadog',
+ },
+ })
+ })
+})
diff --git a/apps/studio/lib/api/self-hosted/log-drains.ts b/apps/studio/lib/api/self-hosted/log-drains.ts
new file mode 100644
index 00000000000..263f238d30e
--- /dev/null
+++ b/apps/studio/lib/api/self-hosted/log-drains.ts
@@ -0,0 +1,44 @@
+import { z } from 'zod'
+
+const LOG_DRAIN_RESOURCE_TYPE = 'log_drain'
+
+const logDrainRequestSchema = z.object({
+ data: z.object({
+ attributes: z.object({
+ name: z.string(),
+ description: z.string().optional(),
+ backend_type: z.string(),
+ config: z.record(z.string(), z.unknown()),
+ }),
+ }),
+})
+
+type LogflareBackend = {
+ token: string
+ name: string
+ description?: string | null
+ type: string
+ config: unknown
+}
+
+/**
+ * Converts a v2 log drain request body ({ data: { attributes } }) into a Logflare backend payload.
+ */
+export function parseLogDrainRequest(body: unknown) {
+ const result = logDrainRequestSchema.safeParse(body)
+ if (!result.success) return { success: false as const, error: result.error }
+
+ const { backend_type, ...attributes } = result.data.data.attributes
+ return { success: true as const, data: { ...attributes, type: backend_type } }
+}
+
+/**
+ * Converts a Logflare backend into a v2 log drain resource, where `id` is the Logflare token.
+ */
+export function asLogDrainResource({ token, name, description, type, config }: LogflareBackend) {
+ return {
+ type: LOG_DRAIN_RESOURCE_TYPE,
+ id: token,
+ attributes: { name, description, config, backend_type: type },
+ }
+}
diff --git a/apps/studio/pages/api/platform/projects/[ref]/analytics/log-drains/[uuid].ts b/apps/studio/pages/api/platform/projects/[ref]/analytics/log-drains/[uuid].ts
deleted file mode 100644
index 8896838e49b..00000000000
--- a/apps/studio/pages/api/platform/projects/[ref]/analytics/log-drains/[uuid].ts
+++ /dev/null
@@ -1,94 +0,0 @@
-import { NextApiRequest, NextApiResponse } from 'next'
-
-import { apiWrapper } from '@/lib/api/apiWrapper'
-import { PROJECT_ANALYTICS_URL } from '@/lib/constants/api'
-
-export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
-
-async function handler(req: NextApiRequest, res: NextApiResponse) {
- const { method } = req
- const { uuid } = req.query
-
- const missingEnvVars = envVarsSet()
-
- if (missingEnvVars !== true) {
- return res
- .status(500)
- .json({ error: { message: `${missingEnvVars.join(', ')} env variables are not set` } })
- }
-
- const baseUrl = PROJECT_ANALYTICS_URL
- if (!baseUrl) {
- return res.status(500).json({ error: { message: `LOGFLARE_URL env variable is not set` } })
- }
-
- switch (method) {
- case 'GET':
- // get log drain
- const url = new URL(baseUrl)
- url.pathname = `/api/backends/${uuid}`
- const result = await fetch(url, {
- method: 'GET',
- headers: {
- Authorization: `Bearer ${process.env.LOGFLARE_PRIVATE_ACCESS_TOKEN}`,
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }).then((r) => r.json())
-
- return res.status(200).json(result)
- case 'PUT':
- // create the log drain
- const putUrl = new URL(baseUrl)
- putUrl.pathname = `/api/backends/${uuid}`
- delete req.body['metadata']
- const putResult = await fetch(putUrl, {
- body: JSON.stringify(req.body),
- method: 'PUT',
- headers: {
- Authorization: `Bearer ${process.env.LOGFLARE_PRIVATE_ACCESS_TOKEN}`,
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- })
- .then(async (r) => await r.json())
- .catch((err) => {
- console.error('error updating log drain', err)
- return res.status(500).json({ error: { message: 'Error updating log drain' } })
- })
- return res.status(200).json(putResult)
-
- case 'DELETE':
- // create the log drain
- const deleteUrl = new URL(baseUrl)
- deleteUrl.pathname = `/api/backends/${uuid}`
-
- await fetch(deleteUrl, {
- headers: {
- Authorization: `Bearer ${process.env.LOGFLARE_PRIVATE_ACCESS_TOKEN}`,
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- method: 'DELETE',
- }).catch((err) => {
- console.error('error deleting log drain', err)
- return res.status(500).json({ error: { message: 'Error deleting log drain' } })
- })
- return res.status(204).json({ error: null })
- default:
- res.setHeader('Allow', ['GET', 'POST'])
- res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
- }
-}
-
-const envVarsSet = () => {
- const missingEnvVars = [
- process.env.LOGFLARE_PRIVATE_ACCESS_TOKEN ? null : 'LOGFLARE_PRIVATE_ACCESS_TOKEN',
- process.env.LOGFLARE_URL ? null : 'LOGFLARE_URL',
- ].filter((v) => v)
- if (missingEnvVars.length == 0) {
- return true
- } else {
- return missingEnvVars
- }
-}
diff --git a/apps/studio/pages/api/platform/projects/[ref]/analytics/log-drains.ts b/apps/studio/pages/api/v2/projects/[ref]/analytics/log-drains.ts
similarity index 84%
rename from apps/studio/pages/api/platform/projects/[ref]/analytics/log-drains.ts
rename to apps/studio/pages/api/v2/projects/[ref]/analytics/log-drains.ts
index 85ad0acd9eb..5835847c702 100644
--- a/apps/studio/pages/api/platform/projects/[ref]/analytics/log-drains.ts
+++ b/apps/studio/pages/api/v2/projects/[ref]/analytics/log-drains.ts
@@ -1,6 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { apiWrapper } from '@/lib/api/apiWrapper'
+import { asLogDrainResource, parseLogDrainRequest } from '@/lib/api/self-hosted/log-drains'
import { PROJECT_ANALYTICS_URL } from '@/lib/constants/api'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -52,15 +53,19 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
.json({ error: { message: 'Unexpected response format from upstream' } })
}
- return res.status(200).json(resp)
+ return res.status(200).json({ data: resp.map(asLogDrainResource) })
case 'POST':
// create the log drain
+ const parsedBody = parseLogDrainRequest(req.body)
+ if (!parsedBody.success) {
+ return res.status(400).json({ error: { message: 'Invalid log drain request body' } })
+ }
+
const postUrl = new URL(baseUrl)
postUrl.pathname = '/api/backends'
- const postResult = await fetch(postUrl, {
+ const postUpstream = await fetch(postUrl, {
body: JSON.stringify({
- ...req.body,
- config: req.body.config,
+ ...parsedBody.data,
metadata: {
type: 'log-drain',
},
@@ -71,7 +76,15 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
'Content-Type': 'application/json',
Accept: 'application/json',
},
- }).then(async (r) => await r.json())
+ })
+
+ if (!postUpstream.ok) {
+ return res
+ .status(500)
+ .json({ error: { message: 'Failed to create log drain in upstream' } })
+ }
+
+ const postResult = await postUpstream.json()
const sourcesGetUrl = new URL(baseUrl)
sourcesGetUrl.pathname = '/api/sources'
@@ -116,7 +129,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
})
)
)
- return res.status(201).json(postResult)
+ return res.status(201).json({ data: asLogDrainResource(postResult) })
default:
res.setHeader('Allow', ['GET', 'POST', 'PUT', 'DELETE'])
diff --git a/apps/studio/pages/api/v2/projects/[ref]/analytics/log-drains/[id].ts b/apps/studio/pages/api/v2/projects/[ref]/analytics/log-drains/[id].ts
new file mode 100644
index 00000000000..502e9158eb6
--- /dev/null
+++ b/apps/studio/pages/api/v2/projects/[ref]/analytics/log-drains/[id].ts
@@ -0,0 +1,101 @@
+import { NextApiRequest, NextApiResponse } from 'next'
+
+import { apiWrapper } from '@/lib/api/apiWrapper'
+import { asLogDrainResource, parseLogDrainRequest } from '@/lib/api/self-hosted/log-drains'
+import { PROJECT_ANALYTICS_URL } from '@/lib/constants/api'
+
+export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
+
+async function handler(req: NextApiRequest, res: NextApiResponse) {
+ const { method } = req
+ const { id } = req.query
+
+ const missingEnvVars = envVarsSet()
+
+ if (missingEnvVars !== true) {
+ return res
+ .status(500)
+ .json({ error: { message: `${missingEnvVars.join(', ')} env variables are not set` } })
+ }
+
+ const baseUrl = PROJECT_ANALYTICS_URL
+ if (!baseUrl) {
+ return res.status(500).json({ error: { message: `LOGFLARE_URL env variable is not set` } })
+ }
+
+ switch (method) {
+ case 'PUT':
+ // update the log drain
+ const parsedBody = parseLogDrainRequest(req.body)
+ if (!parsedBody.success) {
+ return res.status(400).json({ error: { message: 'Invalid log drain request body' } })
+ }
+
+ const putUrl = new URL(baseUrl)
+ putUrl.pathname = `/api/backends/${id}`
+ try {
+ const putUpstream = await fetch(putUrl, {
+ body: JSON.stringify(parsedBody.data),
+ method: 'PUT',
+ headers: {
+ Authorization: `Bearer ${process.env.LOGFLARE_PRIVATE_ACCESS_TOKEN}`,
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ },
+ })
+
+ if (!putUpstream.ok) {
+ return res
+ .status(500)
+ .json({ error: { message: 'Failed to update log drain in upstream' } })
+ }
+
+ const putResult = await putUpstream.json()
+ return res.status(200).json({ data: asLogDrainResource(putResult) })
+ } catch (err) {
+ console.error('error updating log drain', err)
+ return res.status(500).json({ error: { message: 'Error updating log drain' } })
+ }
+
+ case 'DELETE':
+ // delete the log drain
+ const deleteUrl = new URL(baseUrl)
+ deleteUrl.pathname = `/api/backends/${id}`
+
+ try {
+ const deleteUpstream = await fetch(deleteUrl, {
+ headers: {
+ Authorization: `Bearer ${process.env.LOGFLARE_PRIVATE_ACCESS_TOKEN}`,
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ },
+ method: 'DELETE',
+ })
+
+ if (!deleteUpstream.ok) {
+ return res
+ .status(500)
+ .json({ error: { message: 'Failed to delete log drain in upstream' } })
+ }
+ } catch (err) {
+ console.error('error deleting log drain', err)
+ return res.status(500).json({ error: { message: 'Error deleting log drain' } })
+ }
+ return res.status(204).end()
+ default:
+ res.setHeader('Allow', ['PUT', 'DELETE'])
+ res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
+ }
+}
+
+const envVarsSet = () => {
+ const missingEnvVars = [
+ process.env.LOGFLARE_PRIVATE_ACCESS_TOKEN ? null : 'LOGFLARE_PRIVATE_ACCESS_TOKEN',
+ process.env.LOGFLARE_URL ? null : 'LOGFLARE_URL',
+ ].filter((v) => v)
+ if (missingEnvVars.length == 0) {
+ return true
+ } else {
+ return missingEnvVars
+ }
+}
diff --git a/apps/studio/routeTree.gen.ts b/apps/studio/routeTree.gen.ts
index 35170b59492..f5419b5a0b1 100644
--- a/apps/studio/routeTree.gen.ts
+++ b/apps/studio/routeTree.gen.ts
@@ -285,7 +285,6 @@ import { Route as ProjectRefStorageVectorsIndexRouteImport } from './routes/proj
import { Route as ApiPlatformAuthRefUsersIndexRouteImport } from './routes/api/platform/auth/$ref/users/index'
import { Route as ApiPlatformOrganizationsSlugBillingSubscriptionRouteImport } from './routes/api/platform/organizations/$slug/billing/subscription'
import { Route as ApiPlatformPgMetaRefQueryIndexRouteImport } from './routes/api/platform/pg-meta/$ref/query/index'
-import { Route as ApiPlatformProjectsRefAnalyticsLogDrainsRouteImport } from './routes/api/platform/projects/$ref/analytics/log-drains'
import { Route as ApiPlatformProjectsRefApiKeysTemporaryRouteImport } from './routes/api/platform/projects/$ref/api-keys/temporary'
import { Route as ApiPlatformProjectsRefApiGraphqlRouteImport } from './routes/api/platform/projects/$ref/api/graphql'
import { Route as ApiPlatformProjectsRefApiRestRouteImport } from './routes/api/platform/projects/$ref/api/rest'
@@ -302,6 +301,7 @@ import { Route as ApiV1ProjectsRefApiKeysIdRouteImport } from './routes/api/v1/p
import { Route as ApiV1ProjectsRefDatabaseMigrationsRouteImport } from './routes/api/v1/projects/$ref/database/migrations'
import { Route as ApiV1ProjectsRefFunctionsIndexRouteImport } from './routes/api/v1/projects/$ref/functions/index'
import { Route as ApiV1ProjectsRefTypesTypescriptRouteImport } from './routes/api/v1/projects/$ref/types/typescript'
+import { Route as ApiV2ProjectsRefAnalyticsLogDrainsRouteImport } from './routes/api/v2/projects/$ref/analytics/log-drains'
import { Route as ProjectRefIntegrationsIdPageIdIndexRouteImport } from './routes/project/$ref/integrations/$id/$pageId/index'
import { Route as ProjectRefSettingsInfrastructureReplicaReplicaIdRouteImport } from './routes/project/$ref/settings/infrastructure/replica/$replicaId'
import { Route as ProjectRefStorageAnalyticsBucketsBucketIdRouteImport } from './routes/project/$ref/storage/analytics/buckets/$bucketId'
@@ -310,7 +310,6 @@ import { Route as ProjectRefStorageVectorsBucketsBucketIdRouteImport } from './r
import { Route as ApiPlatformAuthRefUsersIdIndexRouteImport } from './routes/api/platform/auth/$ref/users/$id/index'
import { Route as ApiPlatformAuthRefUsersIdFactorsRouteImport } from './routes/api/platform/auth/$ref/users/$id/factors'
import { Route as ApiPlatformProjectsRefAnalyticsEndpointsNameRouteImport } from './routes/api/platform/projects/$ref/analytics/endpoints/$name'
-import { Route as ApiPlatformProjectsRefAnalyticsLogDrainsUuidRouteImport } from './routes/api/platform/projects/$ref/analytics/log-drains/$uuid'
import { Route as ApiPlatformProjectsRefConfigSecretsUpdateStatusRouteImport } from './routes/api/platform/projects/$ref/config/secrets/update-status'
import { Route as ApiPlatformProjectsRefContentFoldersIndexRouteImport } from './routes/api/platform/projects/$ref/content/folders/index'
import { Route as ApiPlatformProjectsRefContentFoldersIdRouteImport } from './routes/api/platform/projects/$ref/content/folders/$id'
@@ -320,6 +319,7 @@ import { Route as ApiPlatformStorageRefBucketsIdEmptyRouteImport } from './route
import { Route as ApiPlatformStorageRefVectorBucketsIdIndexRouteImport } from './routes/api/platform/storage/$ref/vector-buckets/$id/index'
import { Route as ApiV1ProjectsRefFunctionsSlugIndexRouteImport } from './routes/api/v1/projects/$ref/functions/$slug/index'
import { Route as ApiV1ProjectsRefFunctionsSlugBodyRouteImport } from './routes/api/v1/projects/$ref/functions/$slug/body'
+import { Route as ApiV2ProjectsRefAnalyticsLogDrainsIdRouteImport } from './routes/api/v2/projects/$ref/analytics/log-drains/$id'
import { Route as ProjectRefIntegrationsIdPageIdChildIdIndexRouteImport } from './routes/project/$ref/integrations/$id/$pageId/$childId/index'
import { Route as ApiPlatformStorageRefBucketsIdObjectsIndexRouteImport } from './routes/api/platform/storage/$ref/buckets/$id/objects/index'
import { Route as ApiPlatformStorageRefBucketsIdObjectsDownloadRouteImport } from './routes/api/platform/storage/$ref/buckets/$id/objects/download'
@@ -1857,12 +1857,6 @@ const ApiPlatformPgMetaRefQueryIndexRoute =
path: '/api/platform/pg-meta/$ref/query/',
getParentRoute: () => rootRouteImport,
} as any)
-const ApiPlatformProjectsRefAnalyticsLogDrainsRoute =
- ApiPlatformProjectsRefAnalyticsLogDrainsRouteImport.update({
- id: '/api/platform/projects/$ref/analytics/log-drains',
- path: '/api/platform/projects/$ref/analytics/log-drains',
- getParentRoute: () => rootRouteImport,
- } as any)
const ApiPlatformProjectsRefApiKeysTemporaryRoute =
ApiPlatformProjectsRefApiKeysTemporaryRouteImport.update({
id: '/api/platform/projects/$ref/api-keys/temporary',
@@ -1959,6 +1953,12 @@ const ApiV1ProjectsRefTypesTypescriptRoute =
path: '/api/v1/projects/$ref/types/typescript',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiV2ProjectsRefAnalyticsLogDrainsRoute =
+ ApiV2ProjectsRefAnalyticsLogDrainsRouteImport.update({
+ id: '/api/v2/projects/$ref/analytics/log-drains',
+ path: '/api/v2/projects/$ref/analytics/log-drains',
+ getParentRoute: () => rootRouteImport,
+ } as any)
const ProjectRefIntegrationsIdPageIdIndexRoute =
ProjectRefIntegrationsIdPageIdIndexRouteImport.update({
id: '/$id/$pageId/',
@@ -2007,12 +2007,6 @@ const ApiPlatformProjectsRefAnalyticsEndpointsNameRoute =
path: '/api/platform/projects/$ref/analytics/endpoints/$name',
getParentRoute: () => rootRouteImport,
} as any)
-const ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute =
- ApiPlatformProjectsRefAnalyticsLogDrainsUuidRouteImport.update({
- id: '/$uuid',
- path: '/$uuid',
- getParentRoute: () => ApiPlatformProjectsRefAnalyticsLogDrainsRoute,
- } as any)
const ApiPlatformProjectsRefConfigSecretsUpdateStatusRoute =
ApiPlatformProjectsRefConfigSecretsUpdateStatusRouteImport.update({
id: '/api/platform/projects/$ref/config/secrets/update-status',
@@ -2067,6 +2061,12 @@ const ApiV1ProjectsRefFunctionsSlugBodyRoute =
path: '/api/v1/projects/$ref/functions/$slug/body',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiV2ProjectsRefAnalyticsLogDrainsIdRoute =
+ ApiV2ProjectsRefAnalyticsLogDrainsIdRouteImport.update({
+ id: '/$id',
+ path: '/$id',
+ getParentRoute: () => ApiV2ProjectsRefAnalyticsLogDrainsRoute,
+ } as any)
const ProjectRefIntegrationsIdPageIdChildIdIndexRoute =
ProjectRefIntegrationsIdPageIdChildIdIndexRouteImport.update({
id: '/$id/$pageId/$childId/',
@@ -2419,7 +2419,6 @@ export interface FileRoutesByFullPath {
'/project/$ref/storage/files/': typeof ProjectRefStorageFilesIndexRoute
'/project/$ref/storage/vectors/': typeof ProjectRefStorageVectorsIndexRoute
'/api/platform/organizations/$slug/billing/subscription': typeof ApiPlatformOrganizationsSlugBillingSubscriptionRoute
- '/api/platform/projects/$ref/analytics/log-drains': typeof ApiPlatformProjectsRefAnalyticsLogDrainsRouteWithChildren
'/api/platform/projects/$ref/api-keys/temporary': typeof ApiPlatformProjectsRefApiKeysTemporaryRoute
'/api/platform/projects/$ref/api/graphql': typeof ApiPlatformProjectsRefApiGraphqlRoute
'/api/platform/projects/$ref/api/rest': typeof ApiPlatformProjectsRefApiRestRoute
@@ -2430,6 +2429,7 @@ export interface FileRoutesByFullPath {
'/api/v1/projects/$ref/api-keys/$id': typeof ApiV1ProjectsRefApiKeysIdRoute
'/api/v1/projects/$ref/database/migrations': typeof ApiV1ProjectsRefDatabaseMigrationsRoute
'/api/v1/projects/$ref/types/typescript': typeof ApiV1ProjectsRefTypesTypescriptRoute
+ '/api/v2/projects/$ref/analytics/log-drains': typeof ApiV2ProjectsRefAnalyticsLogDrainsRouteWithChildren
'/project/$ref/settings/infrastructure/replica/$replicaId': typeof ProjectRefSettingsInfrastructureReplicaReplicaIdRoute
'/project/$ref/storage/analytics/buckets/$bucketId': typeof ProjectRefStorageAnalyticsBucketsBucketIdRoute
'/project/$ref/storage/files/buckets/$bucketId': typeof ProjectRefStorageFilesBucketsBucketIdRoute
@@ -2445,12 +2445,12 @@ export interface FileRoutesByFullPath {
'/project/$ref/integrations/$id/$pageId/': typeof ProjectRefIntegrationsIdPageIdIndexRoute
'/api/platform/auth/$ref/users/$id/factors': typeof ApiPlatformAuthRefUsersIdFactorsRoute
'/api/platform/projects/$ref/analytics/endpoints/$name': typeof ApiPlatformProjectsRefAnalyticsEndpointsNameRoute
- '/api/platform/projects/$ref/analytics/log-drains/$uuid': typeof ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute
'/api/platform/projects/$ref/config/secrets/update-status': typeof ApiPlatformProjectsRefConfigSecretsUpdateStatusRoute
'/api/platform/projects/$ref/content/folders/$id': typeof ApiPlatformProjectsRefContentFoldersIdRoute
'/api/platform/projects/$ref/content/item/$id': typeof ApiPlatformProjectsRefContentItemIdRoute
'/api/platform/storage/$ref/buckets/$id/empty': typeof ApiPlatformStorageRefBucketsIdEmptyRoute
'/api/v1/projects/$ref/functions/$slug/body': typeof ApiV1ProjectsRefFunctionsSlugBodyRoute
+ '/api/v2/projects/$ref/analytics/log-drains/$id': typeof ApiV2ProjectsRefAnalyticsLogDrainsIdRoute
'/api/platform/auth/$ref/users/$id/': typeof ApiPlatformAuthRefUsersIdIndexRoute
'/api/platform/projects/$ref/content/folders/': typeof ApiPlatformProjectsRefContentFoldersIndexRoute
'/api/platform/storage/$ref/buckets/$id/': typeof ApiPlatformStorageRefBucketsIdIndexRoute
@@ -2728,7 +2728,6 @@ export interface FileRoutesByTo {
'/project/$ref/storage/files': typeof ProjectRefStorageFilesIndexRoute
'/project/$ref/storage/vectors': typeof ProjectRefStorageVectorsIndexRoute
'/api/platform/organizations/$slug/billing/subscription': typeof ApiPlatformOrganizationsSlugBillingSubscriptionRoute
- '/api/platform/projects/$ref/analytics/log-drains': typeof ApiPlatformProjectsRefAnalyticsLogDrainsRouteWithChildren
'/api/platform/projects/$ref/api-keys/temporary': typeof ApiPlatformProjectsRefApiKeysTemporaryRoute
'/api/platform/projects/$ref/api/graphql': typeof ApiPlatformProjectsRefApiGraphqlRoute
'/api/platform/projects/$ref/api/rest': typeof ApiPlatformProjectsRefApiRestRoute
@@ -2739,6 +2738,7 @@ export interface FileRoutesByTo {
'/api/v1/projects/$ref/api-keys/$id': typeof ApiV1ProjectsRefApiKeysIdRoute
'/api/v1/projects/$ref/database/migrations': typeof ApiV1ProjectsRefDatabaseMigrationsRoute
'/api/v1/projects/$ref/types/typescript': typeof ApiV1ProjectsRefTypesTypescriptRoute
+ '/api/v2/projects/$ref/analytics/log-drains': typeof ApiV2ProjectsRefAnalyticsLogDrainsRouteWithChildren
'/project/$ref/settings/infrastructure/replica/$replicaId': typeof ProjectRefSettingsInfrastructureReplicaReplicaIdRoute
'/project/$ref/storage/analytics/buckets/$bucketId': typeof ProjectRefStorageAnalyticsBucketsBucketIdRoute
'/project/$ref/storage/files/buckets/$bucketId': typeof ProjectRefStorageFilesBucketsBucketIdRoute
@@ -2754,12 +2754,12 @@ export interface FileRoutesByTo {
'/project/$ref/integrations/$id/$pageId': typeof ProjectRefIntegrationsIdPageIdIndexRoute
'/api/platform/auth/$ref/users/$id/factors': typeof ApiPlatformAuthRefUsersIdFactorsRoute
'/api/platform/projects/$ref/analytics/endpoints/$name': typeof ApiPlatformProjectsRefAnalyticsEndpointsNameRoute
- '/api/platform/projects/$ref/analytics/log-drains/$uuid': typeof ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute
'/api/platform/projects/$ref/config/secrets/update-status': typeof ApiPlatformProjectsRefConfigSecretsUpdateStatusRoute
'/api/platform/projects/$ref/content/folders/$id': typeof ApiPlatformProjectsRefContentFoldersIdRoute
'/api/platform/projects/$ref/content/item/$id': typeof ApiPlatformProjectsRefContentItemIdRoute
'/api/platform/storage/$ref/buckets/$id/empty': typeof ApiPlatformStorageRefBucketsIdEmptyRoute
'/api/v1/projects/$ref/functions/$slug/body': typeof ApiV1ProjectsRefFunctionsSlugBodyRoute
+ '/api/v2/projects/$ref/analytics/log-drains/$id': typeof ApiV2ProjectsRefAnalyticsLogDrainsIdRoute
'/api/platform/auth/$ref/users/$id': typeof ApiPlatformAuthRefUsersIdIndexRoute
'/api/platform/projects/$ref/content/folders': typeof ApiPlatformProjectsRefContentFoldersIndexRoute
'/api/platform/storage/$ref/buckets/$id': typeof ApiPlatformStorageRefBucketsIdIndexRoute
@@ -3055,7 +3055,6 @@ export interface FileRoutesById {
'/project/$ref/storage/files/': typeof ProjectRefStorageFilesIndexRoute
'/project/$ref/storage/vectors/': typeof ProjectRefStorageVectorsIndexRoute
'/api/platform/organizations/$slug/billing/subscription': typeof ApiPlatformOrganizationsSlugBillingSubscriptionRoute
- '/api/platform/projects/$ref/analytics/log-drains': typeof ApiPlatformProjectsRefAnalyticsLogDrainsRouteWithChildren
'/api/platform/projects/$ref/api-keys/temporary': typeof ApiPlatformProjectsRefApiKeysTemporaryRoute
'/api/platform/projects/$ref/api/graphql': typeof ApiPlatformProjectsRefApiGraphqlRoute
'/api/platform/projects/$ref/api/rest': typeof ApiPlatformProjectsRefApiRestRoute
@@ -3066,6 +3065,7 @@ export interface FileRoutesById {
'/api/v1/projects/$ref/api-keys/$id': typeof ApiV1ProjectsRefApiKeysIdRoute
'/api/v1/projects/$ref/database/migrations': typeof ApiV1ProjectsRefDatabaseMigrationsRoute
'/api/v1/projects/$ref/types/typescript': typeof ApiV1ProjectsRefTypesTypescriptRoute
+ '/api/v2/projects/$ref/analytics/log-drains': typeof ApiV2ProjectsRefAnalyticsLogDrainsRouteWithChildren
'/project/$ref/settings/infrastructure/replica/$replicaId': typeof ProjectRefSettingsInfrastructureReplicaReplicaIdRoute
'/project/$ref/storage/analytics/buckets/$bucketId': typeof ProjectRefStorageAnalyticsBucketsBucketIdRoute
'/project/$ref/storage/files/buckets/$bucketId': typeof ProjectRefStorageFilesBucketsBucketIdRoute
@@ -3081,12 +3081,12 @@ export interface FileRoutesById {
'/project/$ref/integrations/$id/$pageId/': typeof ProjectRefIntegrationsIdPageIdIndexRoute
'/api/platform/auth/$ref/users/$id/factors': typeof ApiPlatformAuthRefUsersIdFactorsRoute
'/api/platform/projects/$ref/analytics/endpoints/$name': typeof ApiPlatformProjectsRefAnalyticsEndpointsNameRoute
- '/api/platform/projects/$ref/analytics/log-drains/$uuid': typeof ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute
'/api/platform/projects/$ref/config/secrets/update-status': typeof ApiPlatformProjectsRefConfigSecretsUpdateStatusRoute
'/api/platform/projects/$ref/content/folders/$id': typeof ApiPlatformProjectsRefContentFoldersIdRoute
'/api/platform/projects/$ref/content/item/$id': typeof ApiPlatformProjectsRefContentItemIdRoute
'/api/platform/storage/$ref/buckets/$id/empty': typeof ApiPlatformStorageRefBucketsIdEmptyRoute
'/api/v1/projects/$ref/functions/$slug/body': typeof ApiV1ProjectsRefFunctionsSlugBodyRoute
+ '/api/v2/projects/$ref/analytics/log-drains/$id': typeof ApiV2ProjectsRefAnalyticsLogDrainsIdRoute
'/api/platform/auth/$ref/users/$id/': typeof ApiPlatformAuthRefUsersIdIndexRoute
'/api/platform/projects/$ref/content/folders/': typeof ApiPlatformProjectsRefContentFoldersIndexRoute
'/api/platform/storage/$ref/buckets/$id/': typeof ApiPlatformStorageRefBucketsIdIndexRoute
@@ -3381,7 +3381,6 @@ export interface FileRouteTypes {
| '/project/$ref/storage/files/'
| '/project/$ref/storage/vectors/'
| '/api/platform/organizations/$slug/billing/subscription'
- | '/api/platform/projects/$ref/analytics/log-drains'
| '/api/platform/projects/$ref/api-keys/temporary'
| '/api/platform/projects/$ref/api/graphql'
| '/api/platform/projects/$ref/api/rest'
@@ -3392,6 +3391,7 @@ export interface FileRouteTypes {
| '/api/v1/projects/$ref/api-keys/$id'
| '/api/v1/projects/$ref/database/migrations'
| '/api/v1/projects/$ref/types/typescript'
+ | '/api/v2/projects/$ref/analytics/log-drains'
| '/project/$ref/settings/infrastructure/replica/$replicaId'
| '/project/$ref/storage/analytics/buckets/$bucketId'
| '/project/$ref/storage/files/buckets/$bucketId'
@@ -3407,12 +3407,12 @@ export interface FileRouteTypes {
| '/project/$ref/integrations/$id/$pageId/'
| '/api/platform/auth/$ref/users/$id/factors'
| '/api/platform/projects/$ref/analytics/endpoints/$name'
- | '/api/platform/projects/$ref/analytics/log-drains/$uuid'
| '/api/platform/projects/$ref/config/secrets/update-status'
| '/api/platform/projects/$ref/content/folders/$id'
| '/api/platform/projects/$ref/content/item/$id'
| '/api/platform/storage/$ref/buckets/$id/empty'
| '/api/v1/projects/$ref/functions/$slug/body'
+ | '/api/v2/projects/$ref/analytics/log-drains/$id'
| '/api/platform/auth/$ref/users/$id/'
| '/api/platform/projects/$ref/content/folders/'
| '/api/platform/storage/$ref/buckets/$id/'
@@ -3690,7 +3690,6 @@ export interface FileRouteTypes {
| '/project/$ref/storage/files'
| '/project/$ref/storage/vectors'
| '/api/platform/organizations/$slug/billing/subscription'
- | '/api/platform/projects/$ref/analytics/log-drains'
| '/api/platform/projects/$ref/api-keys/temporary'
| '/api/platform/projects/$ref/api/graphql'
| '/api/platform/projects/$ref/api/rest'
@@ -3701,6 +3700,7 @@ export interface FileRouteTypes {
| '/api/v1/projects/$ref/api-keys/$id'
| '/api/v1/projects/$ref/database/migrations'
| '/api/v1/projects/$ref/types/typescript'
+ | '/api/v2/projects/$ref/analytics/log-drains'
| '/project/$ref/settings/infrastructure/replica/$replicaId'
| '/project/$ref/storage/analytics/buckets/$bucketId'
| '/project/$ref/storage/files/buckets/$bucketId'
@@ -3716,12 +3716,12 @@ export interface FileRouteTypes {
| '/project/$ref/integrations/$id/$pageId'
| '/api/platform/auth/$ref/users/$id/factors'
| '/api/platform/projects/$ref/analytics/endpoints/$name'
- | '/api/platform/projects/$ref/analytics/log-drains/$uuid'
| '/api/platform/projects/$ref/config/secrets/update-status'
| '/api/platform/projects/$ref/content/folders/$id'
| '/api/platform/projects/$ref/content/item/$id'
| '/api/platform/storage/$ref/buckets/$id/empty'
| '/api/v1/projects/$ref/functions/$slug/body'
+ | '/api/v2/projects/$ref/analytics/log-drains/$id'
| '/api/platform/auth/$ref/users/$id'
| '/api/platform/projects/$ref/content/folders'
| '/api/platform/storage/$ref/buckets/$id'
@@ -4016,7 +4016,6 @@ export interface FileRouteTypes {
| '/project/$ref/storage/files/'
| '/project/$ref/storage/vectors/'
| '/api/platform/organizations/$slug/billing/subscription'
- | '/api/platform/projects/$ref/analytics/log-drains'
| '/api/platform/projects/$ref/api-keys/temporary'
| '/api/platform/projects/$ref/api/graphql'
| '/api/platform/projects/$ref/api/rest'
@@ -4027,6 +4026,7 @@ export interface FileRouteTypes {
| '/api/v1/projects/$ref/api-keys/$id'
| '/api/v1/projects/$ref/database/migrations'
| '/api/v1/projects/$ref/types/typescript'
+ | '/api/v2/projects/$ref/analytics/log-drains'
| '/project/$ref/settings/infrastructure/replica/$replicaId'
| '/project/$ref/storage/analytics/buckets/$bucketId'
| '/project/$ref/storage/files/buckets/$bucketId'
@@ -4042,12 +4042,12 @@ export interface FileRouteTypes {
| '/project/$ref/integrations/$id/$pageId/'
| '/api/platform/auth/$ref/users/$id/factors'
| '/api/platform/projects/$ref/analytics/endpoints/$name'
- | '/api/platform/projects/$ref/analytics/log-drains/$uuid'
| '/api/platform/projects/$ref/config/secrets/update-status'
| '/api/platform/projects/$ref/content/folders/$id'
| '/api/platform/projects/$ref/content/item/$id'
| '/api/platform/storage/$ref/buckets/$id/empty'
| '/api/v1/projects/$ref/functions/$slug/body'
+ | '/api/v2/projects/$ref/analytics/log-drains/$id'
| '/api/platform/auth/$ref/users/$id/'
| '/api/platform/projects/$ref/content/folders/'
| '/api/platform/storage/$ref/buckets/$id/'
@@ -4149,7 +4149,6 @@ export interface RootRouteChildren {
ApiV1ProjectsRefApiKeysRoute: typeof ApiV1ProjectsRefApiKeysRouteWithChildren
ApiPlatformProjectsRefIndexRoute: typeof ApiPlatformProjectsRefIndexRoute
ApiPlatformOrganizationsSlugBillingSubscriptionRoute: typeof ApiPlatformOrganizationsSlugBillingSubscriptionRoute
- ApiPlatformProjectsRefAnalyticsLogDrainsRoute: typeof ApiPlatformProjectsRefAnalyticsLogDrainsRouteWithChildren
ApiPlatformProjectsRefApiKeysTemporaryRoute: typeof ApiPlatformProjectsRefApiKeysTemporaryRoute
ApiPlatformProjectsRefApiGraphqlRoute: typeof ApiPlatformProjectsRefApiGraphqlRoute
ApiPlatformProjectsRefApiRestRoute: typeof ApiPlatformProjectsRefApiRestRoute
@@ -4159,6 +4158,7 @@ export interface RootRouteChildren {
ApiPlatformPropsProjectRefApiRoute: typeof ApiPlatformPropsProjectRefApiRoute
ApiV1ProjectsRefDatabaseMigrationsRoute: typeof ApiV1ProjectsRefDatabaseMigrationsRoute
ApiV1ProjectsRefTypesTypescriptRoute: typeof ApiV1ProjectsRefTypesTypescriptRoute
+ ApiV2ProjectsRefAnalyticsLogDrainsRoute: typeof ApiV2ProjectsRefAnalyticsLogDrainsRouteWithChildren
ApiPlatformAuthRefUsersIndexRoute: typeof ApiPlatformAuthRefUsersIndexRoute
ApiPlatformPgMetaRefQueryIndexRoute: typeof ApiPlatformPgMetaRefQueryIndexRoute
ApiPlatformProjectsRefConfigIndexRoute: typeof ApiPlatformProjectsRefConfigIndexRoute
@@ -6127,13 +6127,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ApiPlatformPgMetaRefQueryIndexRouteImport
parentRoute: typeof rootRouteImport
}
- '/api/platform/projects/$ref/analytics/log-drains': {
- id: '/api/platform/projects/$ref/analytics/log-drains'
- path: '/api/platform/projects/$ref/analytics/log-drains'
- fullPath: '/api/platform/projects/$ref/analytics/log-drains'
- preLoaderRoute: typeof ApiPlatformProjectsRefAnalyticsLogDrainsRouteImport
- parentRoute: typeof rootRouteImport
- }
'/api/platform/projects/$ref/api-keys/temporary': {
id: '/api/platform/projects/$ref/api-keys/temporary'
path: '/api/platform/projects/$ref/api-keys/temporary'
@@ -6246,6 +6239,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ApiV1ProjectsRefTypesTypescriptRouteImport
parentRoute: typeof rootRouteImport
}
+ '/api/v2/projects/$ref/analytics/log-drains': {
+ id: '/api/v2/projects/$ref/analytics/log-drains'
+ path: '/api/v2/projects/$ref/analytics/log-drains'
+ fullPath: '/api/v2/projects/$ref/analytics/log-drains'
+ preLoaderRoute: typeof ApiV2ProjectsRefAnalyticsLogDrainsRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/project/$ref/integrations/$id/$pageId/': {
id: '/project/$ref/integrations/$id/$pageId/'
path: '/$id/$pageId'
@@ -6302,13 +6302,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ApiPlatformProjectsRefAnalyticsEndpointsNameRouteImport
parentRoute: typeof rootRouteImport
}
- '/api/platform/projects/$ref/analytics/log-drains/$uuid': {
- id: '/api/platform/projects/$ref/analytics/log-drains/$uuid'
- path: '/$uuid'
- fullPath: '/api/platform/projects/$ref/analytics/log-drains/$uuid'
- preLoaderRoute: typeof ApiPlatformProjectsRefAnalyticsLogDrainsUuidRouteImport
- parentRoute: typeof ApiPlatformProjectsRefAnalyticsLogDrainsRoute
- }
'/api/platform/projects/$ref/config/secrets/update-status': {
id: '/api/platform/projects/$ref/config/secrets/update-status'
path: '/api/platform/projects/$ref/config/secrets/update-status'
@@ -6372,6 +6365,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ApiV1ProjectsRefFunctionsSlugBodyRouteImport
parentRoute: typeof rootRouteImport
}
+ '/api/v2/projects/$ref/analytics/log-drains/$id': {
+ id: '/api/v2/projects/$ref/analytics/log-drains/$id'
+ path: '/$id'
+ fullPath: '/api/v2/projects/$ref/analytics/log-drains/$id'
+ preLoaderRoute: typeof ApiV2ProjectsRefAnalyticsLogDrainsIdRouteImport
+ parentRoute: typeof ApiV2ProjectsRefAnalyticsLogDrainsRoute
+ }
'/project/$ref/integrations/$id/$pageId/$childId/': {
id: '/project/$ref/integrations/$id/$pageId/$childId/'
path: '/$id/$pageId/$childId'
@@ -7189,19 +7189,19 @@ const ApiV1ProjectsRefApiKeysRouteWithChildren =
ApiV1ProjectsRefApiKeysRouteChildren,
)
-interface ApiPlatformProjectsRefAnalyticsLogDrainsRouteChildren {
- ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute: typeof ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute
+interface ApiV2ProjectsRefAnalyticsLogDrainsRouteChildren {
+ ApiV2ProjectsRefAnalyticsLogDrainsIdRoute: typeof ApiV2ProjectsRefAnalyticsLogDrainsIdRoute
}
-const ApiPlatformProjectsRefAnalyticsLogDrainsRouteChildren: ApiPlatformProjectsRefAnalyticsLogDrainsRouteChildren =
+const ApiV2ProjectsRefAnalyticsLogDrainsRouteChildren: ApiV2ProjectsRefAnalyticsLogDrainsRouteChildren =
{
- ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute:
- ApiPlatformProjectsRefAnalyticsLogDrainsUuidRoute,
+ ApiV2ProjectsRefAnalyticsLogDrainsIdRoute:
+ ApiV2ProjectsRefAnalyticsLogDrainsIdRoute,
}
-const ApiPlatformProjectsRefAnalyticsLogDrainsRouteWithChildren =
- ApiPlatformProjectsRefAnalyticsLogDrainsRoute._addFileChildren(
- ApiPlatformProjectsRefAnalyticsLogDrainsRouteChildren,
+const ApiV2ProjectsRefAnalyticsLogDrainsRouteWithChildren =
+ ApiV2ProjectsRefAnalyticsLogDrainsRoute._addFileChildren(
+ ApiV2ProjectsRefAnalyticsLogDrainsRouteChildren,
)
const rootRouteChildren: RootRouteChildren = {
@@ -7293,8 +7293,6 @@ const rootRouteChildren: RootRouteChildren = {
ApiPlatformProjectsRefIndexRoute: ApiPlatformProjectsRefIndexRoute,
ApiPlatformOrganizationsSlugBillingSubscriptionRoute:
ApiPlatformOrganizationsSlugBillingSubscriptionRoute,
- ApiPlatformProjectsRefAnalyticsLogDrainsRoute:
- ApiPlatformProjectsRefAnalyticsLogDrainsRouteWithChildren,
ApiPlatformProjectsRefApiKeysTemporaryRoute:
ApiPlatformProjectsRefApiKeysTemporaryRoute,
ApiPlatformProjectsRefApiGraphqlRoute: ApiPlatformProjectsRefApiGraphqlRoute,
@@ -7309,6 +7307,8 @@ const rootRouteChildren: RootRouteChildren = {
ApiV1ProjectsRefDatabaseMigrationsRoute:
ApiV1ProjectsRefDatabaseMigrationsRoute,
ApiV1ProjectsRefTypesTypescriptRoute: ApiV1ProjectsRefTypesTypescriptRoute,
+ ApiV2ProjectsRefAnalyticsLogDrainsRoute:
+ ApiV2ProjectsRefAnalyticsLogDrainsRouteWithChildren,
ApiPlatformAuthRefUsersIndexRoute: ApiPlatformAuthRefUsersIndexRoute,
ApiPlatformPgMetaRefQueryIndexRoute: ApiPlatformPgMetaRefQueryIndexRoute,
ApiPlatformProjectsRefConfigIndexRoute:
diff --git a/apps/studio/routes/api/platform/projects/$ref/analytics/log-drains/$uuid.ts b/apps/studio/routes/api/platform/projects/$ref/analytics/log-drains/$uuid.ts
deleted file mode 100644
index 18393f0b339..00000000000
--- a/apps/studio/routes/api/platform/projects/$ref/analytics/log-drains/$uuid.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { createFileRoute } from '@tanstack/react-router'
-
-import { toWebHandler } from '@/compat/next/api'
-import nextHandler from '@/pages/api/platform/projects/[ref]/analytics/log-drains/[uuid]'
-
-const handler = toWebHandler(nextHandler)
-
-export const Route = createFileRoute('/api/platform/projects/$ref/analytics/log-drains/$uuid')({
- server: { handlers: { GET: handler, PUT: handler, DELETE: handler } },
-})
diff --git a/apps/studio/routes/api/platform/projects/$ref/analytics/log-drains.ts b/apps/studio/routes/api/v2/projects/$ref/analytics/log-drains.ts
similarity index 54%
rename from apps/studio/routes/api/platform/projects/$ref/analytics/log-drains.ts
rename to apps/studio/routes/api/v2/projects/$ref/analytics/log-drains.ts
index dedabca706a..f9ba30ec6ba 100644
--- a/apps/studio/routes/api/platform/projects/$ref/analytics/log-drains.ts
+++ b/apps/studio/routes/api/v2/projects/$ref/analytics/log-drains.ts
@@ -1,10 +1,10 @@
import { createFileRoute } from '@tanstack/react-router'
import { toWebHandler } from '@/compat/next/api'
-import nextHandler from '@/pages/api/platform/projects/[ref]/analytics/log-drains'
+import nextHandler from '@/pages/api/v2/projects/[ref]/analytics/log-drains'
const handler = toWebHandler(nextHandler)
-export const Route = createFileRoute('/api/platform/projects/$ref/analytics/log-drains')({
+export const Route = createFileRoute('/api/v2/projects/$ref/analytics/log-drains')({
server: { handlers: { GET: handler, POST: handler } },
})
diff --git a/apps/studio/routes/api/v2/projects/$ref/analytics/log-drains/$id.ts b/apps/studio/routes/api/v2/projects/$ref/analytics/log-drains/$id.ts
new file mode 100644
index 00000000000..de2c148e5cb
--- /dev/null
+++ b/apps/studio/routes/api/v2/projects/$ref/analytics/log-drains/$id.ts
@@ -0,0 +1,10 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+import { toWebHandler } from '@/compat/next/api'
+import nextHandler from '@/pages/api/v2/projects/[ref]/analytics/log-drains/[id]'
+
+const handler = toWebHandler(nextHandler)
+
+export const Route = createFileRoute('/api/v2/projects/$ref/analytics/log-drains/$id')({
+ server: { handlers: { PUT: handler, DELETE: handler } },
+})
diff --git a/e2e/studio/features/log-drains.spec.ts b/e2e/studio/features/log-drains.spec.ts
index ab2a7412a33..cfc06c66ed2 100644
--- a/e2e/studio/features/log-drains.spec.ts
+++ b/e2e/studio/features/log-drains.spec.ts
@@ -19,7 +19,7 @@ const LOG_DRAIN_OPTIONS = [
]
test.describe('Log Drains Settings', () => {
- test.skip(env.IS_PLATFORM, 'Log drains are not supported on platform')
+ test.skip(env.IS_PLATFORM, 'Log drains e2e tests only run against self-hosted')
test.beforeEach(async ({ page, ref }) => {
// Navigate to the log drains settings page