Skip to content

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

fix: api types + remove old telemetry (#30096)

Alaister Young7e360731a38c
diff --git a/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx
index 16f566b15a7..81c22e953ea 100644
--- a/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx
+++ b/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx
@@ -2,22 +2,15 @@ import { Toggle } from 'ui'
import Panel from 'components/ui/Panel'
import { useSendResetMutation } from 'data/telemetry/send-reset-mutation'
-import { useFlag } from 'hooks/ui/useFlag'
-import { LOCAL_STORAGE_KEYS } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
const AnalyticsSettings = () => {
const snap = useAppStateSnapshot()
- const enablePostHogTelemetry = useFlag('enablePosthogChanges')
const { mutate: sendReset } = useSendResetMutation()
- const consentFlag = enablePostHogTelemetry
- ? LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH
- : LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT
-
const onToggleOptIn = () => {
const value = !snap.isOptedInTelemetry ? 'true' : 'false'
- snap.setIsOptedInTelemetry(value === 'true', consentFlag)
+ snap.setIsOptedInTelemetry(value === 'true')
if (value === 'false') sendReset()
}
diff --git a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
index 3debb82a26a..bb5424c43ac 100644
--- a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
+++ b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
@@ -4,6 +4,7 @@ import { PropsWithChildren, useEffect } from 'react'
import PartnerIcon from 'components/ui/PartnerIcon'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
+import { useSendResetMutation } from 'data/telemetry/send-reset-mutation'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { withAuth } from 'hooks/misc/withAuth'
import { useFlag } from 'hooks/ui/useFlag'
@@ -12,7 +13,6 @@ import { IS_PLATFORM } from 'lib/constants'
import SettingsLayout from '../SettingsLayout/SettingsLayout'
import type { SidebarSection } from './AccountLayout.types'
import WithSidebar from './WithSidebar'
-import { useSendResetMutation } from 'data/telemetry/send-reset-mutation'
export interface AccountLayoutProps {
title: string
@@ -28,12 +28,11 @@ const AccountLayout = ({ children, title, breadcrumbs }: PropsWithChildren<Accou
const selectedOrganization = useSelectedOrganization()
const navLayoutV2 = useFlag('navigationLayoutV2')
- const enablePostHogTelemetry = useFlag('enablePosthogChanges')
const { mutateAsync: sendReset } = useSendResetMutation()
const signOut = useSignOut()
const onClickLogout = async () => {
- if (enablePostHogTelemetry) await sendReset()
+ await sendReset()
await signOut()
await router.push('/sign-in')
}
diff --git a/apps/studio/components/ui/PageTelemetry.tsx b/apps/studio/components/ui/PageTelemetry.tsx
index ad98b7e96ac..662cbd62e02 100644
--- a/apps/studio/components/ui/PageTelemetry.tsx
+++ b/apps/studio/components/ui/PageTelemetry.tsx
@@ -11,7 +11,6 @@ import { useSendPageLeaveMutation } from 'data/telemetry/send-page-leave-mutatio
import { useSendPageMutation } from 'data/telemetry/send-page-mutation'
import { usePrevious } from 'hooks/deprecated'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
-import { useFlag } from 'hooks/ui/useFlag'
import { IS_PLATFORM, LOCAL_STORAGE_KEYS } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
import { ConsentToast } from 'ui-patterns/ConsentToast'
@@ -34,13 +33,11 @@ const PageTelemetry = ({ children }: PropsWithChildren<{}>) => {
const consentToastId = useRef<string | number>()
const previousPathname = usePrevious(router.pathname)
- const enablePostHogTelemetry = useFlag('enablePosthogChanges')
- const consentFlag = enablePostHogTelemetry
- ? LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH
- : LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT
+ const consentFlag = LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT
+
const consent = typeof window !== 'undefined' ? localStorage.getItem(consentFlag) : null
- const trackTelemetryPH = enablePostHogTelemetry && consent === 'true'
+ const trackTelemetryPH = consent === 'true'
const { mutate: sendPage } = useSendPageMutation()
const { mutateAsync: sendPageLeave } = useSendPageLeaveMutation()
@@ -48,27 +45,22 @@ const PageTelemetry = ({ children }: PropsWithChildren<{}>) => {
const { mutate: sendGroupsReset } = useSendGroupsResetMutation()
useEffect(() => {
- if (typeof window !== 'undefined' && enablePostHogTelemetry !== undefined) {
+ if (typeof window !== 'undefined') {
const onAcceptConsent = () => {
- snap.setIsOptedInTelemetry(true, consentFlag)
+ snap.setIsOptedInTelemetry(true)
if (consentToastId.current) toast.dismiss(consentToastId.current)
}
const onOptOut = () => {
- snap.setIsOptedInTelemetry(false, consentFlag)
+ snap.setIsOptedInTelemetry(false)
if (consentToastId.current) toast.dismiss(consentToastId.current)
}
- const hasAcknowledgedConsent = localStorage.getItem(
- enablePostHogTelemetry
- ? LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH
- : LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT
- )
+ const hasAcknowledgedConsent = localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
snap.setIsOptedInTelemetry(
typeof hasAcknowledgedConsent === 'string'
? hasAcknowledgedConsent === 'true'
- : hasAcknowledgedConsent,
- consentFlag
+ : hasAcknowledgedConsent
)
if (IS_PLATFORM && hasAcknowledgedConsent === null) {
@@ -86,7 +78,7 @@ const PageTelemetry = ({ children }: PropsWithChildren<{}>) => {
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [enablePostHogTelemetry])
+ }, [])
useEffect(() => {
function handleRouteChange() {
@@ -163,7 +155,7 @@ const PageTelemetry = ({ children }: PropsWithChildren<{}>) => {
useEffect(() => {
const handleBeforeUnload = async () => {
- if (enablePostHogTelemetry && snap.isOptedInTelemetry) await sendPageLeave()
+ if (snap.isOptedInTelemetry) await sendPageLeave()
}
window.addEventListener('beforeunload', handleBeforeUnload)
diff --git a/apps/studio/data/telemetry/send-event-mutation.ts b/apps/studio/data/telemetry/send-event-mutation.ts
index c2a22289c48..1fe377f8c4e 100644
--- a/apps/studio/data/telemetry/send-event-mutation.ts
+++ b/apps/studio/data/telemetry/send-event-mutation.ts
@@ -3,13 +3,11 @@ import { components } from 'api-types'
import { isBrowser } from 'common'
import { handleError, post } from 'data/fetchers'
-import { useFlag } from 'hooks/ui/useFlag'
import { LOCAL_STORAGE_KEYS } from 'lib/constants'
import { useRouter } from 'next/router'
import type { ResponseError } from 'types'
-type SendEventGA = components['schemas']['TelemetryEventBody']
-type SendEventPH = components['schemas']['TelemetryEventBodyV2']
+type SendEvent = components['schemas']['TelemetryEventBodyV2']
export type SendEventVariables = {
action: string
@@ -20,18 +18,15 @@ export type SendEventVariables = {
type SendEventPayload = any
-export async function sendEvent({
- consent,
- type,
- body,
-}: {
- consent: boolean
- type: 'GA' | 'PH'
- body: SendEventPayload
-}) {
+export async function sendEvent({ body }: { body: SendEventPayload }) {
+ const consent =
+ (typeof window !== 'undefined'
+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
+ : null) === 'true'
+
if (!consent) return undefined
- const headers = type === 'PH' ? { Version: '2' } : undefined
+ const headers = { Version: '2' }
const { data, error } = await post(`/platform/telemetry/event`, { body, headers })
if (error) handleError(error)
return data
@@ -48,22 +43,16 @@ export const useSendEventMutation = ({
'mutationFn'
> = {}) => {
const router = useRouter()
- const usePostHogParameters = useFlag('enablePosthogChanges')
-
- const consent =
- (typeof window !== 'undefined'
- ? localStorage.getItem(
- usePostHogParameters
- ? LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH
- : LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT
- )
- : null) === 'true'
const title = typeof document !== 'undefined' ? document?.title : ''
const referrer = typeof document !== 'undefined' ? document?.referrer : ''
- const payload = usePostHogParameters
- ? ({
+ return useMutation<SendEventData, ResponseError, SendEventVariables>(
+ (vars) => {
+ const { action, ...otherVars } = vars
+
+ const body: SendEvent = {
+ action,
page_url: window.location.href,
page_title: title,
pathname: router.pathname,
@@ -75,30 +64,11 @@ export const useSendEventMutation = ({
viewport_height: isBrowser ? window.innerHeight : 0,
viewport_width: isBrowser ? window.innerWidth : 0,
},
- custom_properties: {},
- } as SendEventPH)
- : ({
- page_referrer: referrer,
- page_title: title,
- page_location: router.asPath.split('#')[0],
- ga: {
- screen_resolution: isBrowser ? `${window.innerWidth}x${window.innerHeight}` : undefined,
- language: router?.locale ?? 'en-US',
- },
- } as SendEventGA)
+ // @ts-expect-error - API is returning a wrong type
+ custom_properties: otherVars,
+ }
- return useMutation<SendEventData, ResponseError, SendEventVariables>(
- (vars) => {
- const { action, ...otherVars } = vars
- const type = usePostHogParameters ? 'PH' : 'GA'
- const body = usePostHogParameters
- ? ({
- action,
- ...(payload as Omit<SendEventPH, 'action'>),
- custom_properties: otherVars,
- } as unknown as SendEventPH)
- : ({ ...vars, ...payload } as SendEventGA)
- return sendEvent({ consent, type, body })
+ return sendEvent({ body })
},
{
async onSuccess(data, variables, context) {
diff --git a/apps/studio/data/telemetry/send-groups-identify-mutation.ts b/apps/studio/data/telemetry/send-groups-identify-mutation.ts
index 04bd2673623..128ecdff8f5 100644
--- a/apps/studio/data/telemetry/send-groups-identify-mutation.ts
+++ b/apps/studio/data/telemetry/send-groups-identify-mutation.ts
@@ -7,13 +7,12 @@ import type { ResponseError } from 'types'
export type SendGroupsIdentifyVariables = components['schemas']['TelemetryGroupsIdentityBody']
-export async function sendGroupsIdentify({
- consent,
- body,
-}: {
- consent: boolean
- body: SendGroupsIdentifyVariables
-}) {
+export async function sendGroupsIdentify({ body }: { body: SendGroupsIdentifyVariables }) {
+ const consent =
+ (typeof window !== 'undefined'
+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
+ : null) === 'true'
+
if (!consent) return undefined
const { data, error } = await post(`/platform/telemetry/groups/identify`, {
@@ -34,13 +33,8 @@ export const useSendGroupsIdentifyMutation = ({
UseMutationOptions<SendGroupsIdentifyData, ResponseError, SendGroupsIdentifyVariables>,
'mutationFn'
> = {}) => {
- const consent =
- (typeof window !== 'undefined'
- ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH)
- : null) === 'true'
-
return useMutation<SendGroupsIdentifyData, ResponseError, SendGroupsIdentifyVariables>(
- (vars) => sendGroupsIdentify({ consent, body: vars }),
+ (vars) => sendGroupsIdentify({ body: vars }),
{
async onSuccess(data, variables, context) {
await onSuccess?.(data, variables, context)
diff --git a/apps/studio/data/telemetry/send-groups-reset-mutation.ts b/apps/studio/data/telemetry/send-groups-reset-mutation.ts
index 3523235426c..435834fd1e4 100644
--- a/apps/studio/data/telemetry/send-groups-reset-mutation.ts
+++ b/apps/studio/data/telemetry/send-groups-reset-mutation.ts
@@ -7,13 +7,12 @@ import type { ResponseError } from 'types'
export type SendGroupsResetVariables = components['schemas']['TelemetryGroupsResetBody']
-export async function sendGroupsReset({
- consent,
- body,
-}: {
- consent: boolean
- body: SendGroupsResetVariables
-}) {
+export async function sendGroupsReset({ body }: { body: SendGroupsResetVariables }) {
+ const consent =
+ (typeof window !== 'undefined'
+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
+ : null) === 'true'
+
if (!consent) return undefined
const { data, error } = await post(`/platform/telemetry/groups/reset`, {
@@ -34,13 +33,8 @@ export const useSendGroupsResetMutation = ({
UseMutationOptions<SendGroupsResetData, ResponseError, SendGroupsResetVariables>,
'mutationFn'
> = {}) => {
- const consent =
- (typeof window !== 'undefined'
- ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH)
- : null) === 'true'
-
return useMutation<SendGroupsResetData, ResponseError, SendGroupsResetVariables>(
- (vars) => sendGroupsReset({ consent, body: vars }),
+ (vars) => sendGroupsReset({ body: vars }),
{
async onSuccess(data, variables, context) {
await onSuccess?.(data, variables, context)
diff --git a/apps/studio/data/telemetry/send-identify-mutation.ts b/apps/studio/data/telemetry/send-identify-mutation.ts
index ad63eb75d6f..733f7ac4f60 100644
--- a/apps/studio/data/telemetry/send-identify-mutation.ts
+++ b/apps/studio/data/telemetry/send-identify-mutation.ts
@@ -1,16 +1,12 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
-import { useRouter } from 'next/router'
import { components } from 'api-types'
-import { isBrowser } from 'common'
import { handleError, post } from 'data/fetchers'
import { Profile } from 'data/profile/types'
-import { useFlag } from 'hooks/ui/useFlag'
import { LOCAL_STORAGE_KEYS } from 'lib/constants'
import type { ResponseError } from 'types'
-type SendIdentifyGA = components['schemas']['TelemetryIdentifyBody']
-type SendIdentifyPH = components['schemas']['TelemetryIdentifyBodyV2']
+type SendIdentify = components['schemas']['TelemetryIdentifyBodyV2']
export type SendIdentifyVariables = {
slug?: string
@@ -20,18 +16,15 @@ export type SendIdentifyVariables = {
type SendIdentifyPayload = any
-export async function sendIdentify({
- consent,
- type,
- body,
-}: {
- consent: boolean
- type: 'GA' | 'PH'
- body: SendIdentifyPayload
-}) {
+export async function sendIdentify({ body }: { body: SendIdentifyPayload }) {
+ const consent =
+ (typeof window !== 'undefined'
+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
+ : null) === 'true'
+
if (!consent) return undefined
- const headers = type === 'PH' ? { Version: '2' } : undefined
+ const headers = { Version: '2' }
const { data, error } = await post(`/platform/telemetry/identify`, { body, headers })
if (error) handleError(error)
return data
@@ -47,40 +40,17 @@ export const useSendIdentifyMutation = ({
UseMutationOptions<SendIdentifyData, ResponseError, SendIdentifyVariables>,
'mutationFn'
> = {}) => {
- const router = useRouter()
- const usePostHogParameters = useFlag('enablePosthogChanges')
-
- const consent =
- (typeof window !== 'undefined'
- ? localStorage.getItem(
- usePostHogParameters
- ? LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH
- : LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT
- )
- : null) === 'true'
-
- const payload = usePostHogParameters
- ? ({} as SendIdentifyPH)
- : ({
- ga: {
- screen_resolution: isBrowser ? `${window.innerWidth}x${window.innerHeight}` : undefined,
- language: router?.locale ?? 'en-US',
- },
- } as SendIdentifyGA)
-
return useMutation<SendIdentifyData, ResponseError, SendIdentifyVariables>(
(vars) => {
const { user, slug, ref } = vars
- const { disabled_features, ...userInfo } = user
- const type = usePostHogParameters ? 'PH' : 'GA'
- const body = usePostHogParameters
- ? ({
- user_id: user.gotrue_id,
- organization_slug: slug,
- project_ref: ref,
- } as SendIdentifyPH)
- : ({ user: userInfo, ...payload } as SendIdentifyGA)
- return sendIdentify({ consent, type, body })
+
+ const body: SendIdentify = {
+ user_id: user.gotrue_id,
+ organization_slug: slug,
+ project_ref: ref,
+ }
+
+ return sendIdentify({ body })
},
{
async onSuccess(data, variables, context) {
diff --git a/apps/studio/data/telemetry/send-page-leave-mutation.ts b/apps/studio/data/telemetry/send-page-leave-mutation.ts
index ad187b4ea07..366931b13bd 100644
--- a/apps/studio/data/telemetry/send-page-leave-mutation.ts
+++ b/apps/studio/data/telemetry/send-page-leave-mutation.ts
@@ -2,20 +2,18 @@ import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { components } from 'api-types'
import { handleError, post } from 'data/fetchers'
-import { useFlag } from 'hooks/ui/useFlag'
import { LOCAL_STORAGE_KEYS } from 'lib/constants'
import { useRouter } from 'next/router'
import type { ResponseError } from 'types'
type SendPageLeaveBody = components['schemas']['TelemetryPageLeaveBody']
-export async function sendPageLeave({
- consent,
- body,
-}: {
- consent: boolean
- body: SendPageLeaveBody
-}) {
+export async function sendPageLeave({ body }: { body: SendPageLeaveBody }) {
+ const consent =
+ (typeof window !== 'undefined'
+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
+ : null) === 'true'
+
if (!consent) return undefined
const { data, error } = await post(`/platform/telemetry/page-leave`, {
@@ -34,10 +32,6 @@ export const useSendPageLeaveMutation = ({
...options
}: Omit<UseMutationOptions<SendPageLeaveData, ResponseError>, 'mutationFn'> = {}) => {
const router = useRouter()
- const consent =
- (typeof window !== 'undefined'
- ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH)
- : null) === 'true'
const url = typeof window !== 'undefined' ? window.location.href : ''
const title = typeof document !== 'undefined' ? document?.title : ''
@@ -48,7 +42,7 @@ export const useSendPageLeaveMutation = ({
pathname: router.pathname,
} as SendPageLeaveBody
- return useMutation<SendPageLeaveData, ResponseError>((vars) => sendPageLeave({ consent, body }), {
+ return useMutation<SendPageLeaveData, ResponseError>((vars) => sendPageLeave({ body }), {
async onSuccess(data, variables, context) {
await onSuccess?.(data, variables, context)
},
diff --git a/apps/studio/data/telemetry/send-page-mutation.ts b/apps/studio/data/telemetry/send-page-mutation.ts
index 6d3d7a67499..ad32f1b6336 100644
--- a/apps/studio/data/telemetry/send-page-mutation.ts
+++ b/apps/studio/data/telemetry/send-page-mutation.ts
@@ -3,13 +3,11 @@ import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { components } from 'api-types'
import { isBrowser } from 'common'
import { handleError, post } from 'data/fetchers'
-import { useFlag } from 'hooks/ui/useFlag'
import { LOCAL_STORAGE_KEYS } from 'lib/constants'
import { useRouter } from 'next/router'
import type { ResponseError } from 'types'
-type SendPageGA = components['schemas']['TelemetryPageBody']
-type SendPagePH = components['schemas']['TelemetryPageBodyV2']
+type SendPage = components['schemas']['TelemetryPageBodyV2']
export type SendPageVariables = {
url: string
@@ -17,18 +15,15 @@ export type SendPageVariables = {
type SendPagePayload = any
-export async function sendPage({
- consent,
- type,
- body,
-}: {
- consent: boolean
- type: 'GA' | 'PH'
- body: SendPagePayload
-}) {
+export async function sendPage({ body }: { body: SendPagePayload }) {
+ const consent =
+ (typeof window !== 'undefined'
+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
+ : null) === 'true'
+
if (!consent) return undefined
- const headers = type === 'PH' ? { Version: '2' } : undefined
+ const headers = { Version: '2' }
const { data, error } = await post(`/platform/telemetry/page`, { body, headers })
if (error) handleError(error)
return data
@@ -42,22 +37,16 @@ export const useSendPageMutation = ({
...options
}: Omit<UseMutationOptions<SendPageData, ResponseError, SendPageVariables>, 'mutationFn'> = {}) => {
const router = useRouter()
- const usePostHogParameters = useFlag('enablePosthogChanges')
-
- const consent =
- (typeof window !== 'undefined'
- ? localStorage.getItem(
- usePostHogParameters
- ? LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT_PH
- : LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT
- )
- : null) === 'true'
const title = typeof document !== 'undefined' ? document?.title : ''
const referrer = typeof document !== 'undefined' ? document?.referrer : ''
- const payload = usePostHogParameters
- ? ({
+ return useMutation<SendPageData, ResponseError, SendPageVariables>(
+ (vars) => {
+ const { url } = vars
+ const type = 'PH'
+ const body: SendPage = {
+ page_url: url,
page_title: title,
pathname: router.pathname,
ph: {
@@ -68,24 +57,8 @@ export const useSendPageMutation = ({
viewport_height: isBrowser ? window.innerHeight : 0,
viewport_width: isBrowser ? window.innerWidth : 0,
},
- } as SendPagePH)
- : ({
- title,
- referrer,
- ga: {
- screen_resolution: isBrowser ? `${window.innerWidth}x${window.innerHeight}` : undefined,
- language: router?.locale ?? 'en-US',
- },
- } as SendPageGA)
-
- return useMutation<SendPageData, ResponseError, SendPageVariables>(
- (vars) => {
- const { url } = vars
- const type = usePostHogParameters ? 'PH' : 'GA'
- const body = usePostHogParameters
- ? ({ page_url: url, ...payload } as SendPagePH)
- : ({ route: url, ...payload } as SendPageGA)
- return sendPage({ consent, type, body })
+ }
+ return sendPage({ body })
},
{
async onSuccess(data, variables, context) {
diff --git a/apps/studio/lib/constants/index.ts b/apps/studio/lib/constants/index.ts
index d7e7533b55f..15a3cb2af51 100644
--- a/apps/studio/lib/constants/index.ts
+++ b/apps/studio/lib/constants/index.ts
@@ -29,9 +29,7 @@ export const USAGE_APPROACHING_THRESHOLD = 0.75
export const LOCAL_STORAGE_KEYS = {
RECENTLY_VISITED_ORGANIZATION: 'supabase-organization',
- TELEMETRY_CONSENT: 'supabase-consent',
- // Used for when we enable PH for telemetry instead of GA
- TELEMETRY_CONSENT_PH: 'supabase-consent-ph',
+ TELEMETRY_CONSENT: 'supabase-consent-ph',
UI_PREVIEW_NAVIGATION_LAYOUT: 'supabase-ui-preview-nav-layout',
UI_PREVIEW_API_SIDE_PANEL: 'supabase-ui-api-side-panel',
diff --git a/apps/studio/pages/api/organizations/[slug]/billing/subscription.ts b/apps/studio/pages/api/organizations/[slug]/billing/subscription.ts
index ed1da8d5d54..5baa6aa7966 100644
--- a/apps/studio/pages/api/organizations/[slug]/billing/subscription.ts
+++ b/apps/studio/pages/api/organizations/[slug]/billing/subscription.ts
@@ -38,7 +38,6 @@ const handleGet = async (req: NextApiRequest, res: NextApiResponse<ResponseData>
scheduled_plan_change: null,
customer_balance: 0,
nano_enabled: false,
- usage_based_billing_project_addons: false,
}
return res.status(200).json(response)
diff --git a/apps/studio/state/app-state.ts b/apps/studio/state/app-state.ts
index 3e5902c7cc4..807e7815c97 100644
--- a/apps/studio/state/app-state.ts
+++ b/apps/studio/state/app-state.ts
@@ -43,16 +43,11 @@ export const appState = proxy({
},
isOptedInTelemetry: false,
- setIsOptedInTelemetry: (value: boolean | null, flag = LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT) => {
+ setIsOptedInTelemetry: (value: boolean | null) => {
appState.isOptedInTelemetry = value === null ? false : value
if (typeof window !== 'undefined' && value !== null) {
- localStorage.setItem(flag, value.toString())
+ localStorage.setItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT, value.toString())
}
- // [Joshen] Eventually once we completely move to PH, we should just set local storage
- // directly here, but since currently it's dependent on a feature flag, will need to pass in as a prop
- // if (typeof window !== 'undefined') {
- // localStorage.setItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT, value.toString())
- // }
},
showEnableBranchingModal: false,
setShowEnableBranchingModal: (value: boolean) => {
diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.ts
index b9504458a6e..a4cc902717f 100644
--- a/packages/api-types/types/api.d.ts
+++ b/packages/api-types/types/api.d.ts
@@ -344,10 +344,6 @@ export interface paths {
/** Preview subscription changes */
post: operations['SubscriptionController_previewSubscriptionChange']
}
- '/platform/organizations/{slug}/billing/subscription/schedule': {
- /** Deletes any upcoming subscription schedule */
- delete: operations['SubscriptionController_deleteSubscriptionSchedule']
- }
'/platform/organizations/{slug}/customer': {
/** Gets the Stripe customer */
get: operations['CustomerController_getCustomer']
@@ -480,12 +476,10 @@ export interface paths {
get: operations['OrganizationRolesController_getAllRolesV2']
}
'/platform/organizations/{slug}/tax-ids': {
- /** Gets the given organization's tax IDs */
- get: operations['TaxIdsController_getTaxIds']
+ /** Gets the given organization's tax ID */
+ get: operations['TaxIdsController_getTaxId']
/** Creates or updates a tax ID for the given organization */
put: operations['TaxIdsController_updateTaxId']
- /** Creates a tax ID for the given organization */
- post: operations['TaxIdsController_createTaxId']
/** Delete the tax ID with the given ID */
delete: operations['TaxIdsController_deleteTaxId']
}
@@ -783,6 +777,10 @@ export interface paths {
/** Lists project's warehouse queries from logflare */
get: operations['v1-list-all-warehouse-queries']
}
+ '/platform/projects/{ref}/analytics/warehouse/query/parse': {
+ /** Parses a warehouse query */
+ get: operations['v1-parse-warehouse-query']
+ }
'/platform/projects/{ref}/analytics/warehouse/tenant': {
/** Gets project's warehouse tenant from logflare */
get: operations['v1-provision-a-warehouse-tenant']
@@ -1702,6 +1700,10 @@ export interface paths {
/** Lists project's warehouse queries from logflare */
get: operations['v1-list-all-warehouse-queries']
}
+ '/v0/projects/{ref}/analytics/warehouse/query/parse': {
+ /** Parses a warehouse query */
+ get: operations['v1-parse-warehouse-query']
+ }
'/v0/projects/{ref}/analytics/warehouse/tenant': {
/** Gets project's warehouse tenant from logflare */
get: operations['v1-provision-a-warehouse-tenant']
@@ -3026,13 +3028,6 @@ export interface components {
type: string
value: string
}
- CreateTaxIdResponse: {
- country: string
- created: number
- id: string
- type: string
- value: string
- }
CreateThirdPartyAuthBody: {
custom_jwks?: Record<string, never>
jwks_url?: string
@@ -3296,9 +3291,6 @@ export interface components {
saml?: components['schemas']['SamlDescriptor']
updated_at?: string
}
- DeleteTaxIdBody: {
- id: string
- }
DeleteVercelConnectionResponse: {
id: string
}
@@ -3607,7 +3599,6 @@ export interface components {
plan: components['schemas']['BillingSubscriptionPlan']
project_addons: components['schemas']['BillingProjectAddonResponse'][]
scheduled_plan_change: components['schemas']['ScheduledPlanChange'] | null
- usage_based_billing_project_addons: boolean
usage_billing_enabled: boolean
}
GetUserContentByIdResponse: {
@@ -3702,11 +3693,6 @@ export interface components {
sender_id: number
user_id: number
}
- GoogleAnalyticBody: {
- language?: string
- screen_resolution?: string
- session_id: string
- }
GoTrueConfigResponse: {
API_MAX_REQUEST_DURATION: number | null
DB_MAX_POOL_SIZE: number | null
@@ -3907,18 +3893,6 @@ export interface components {
HealthResponse: {
healthy: boolean
}
- IdentifyUserBody: {
- auth0_id?: string
- first_name?: string
- free_project_limit?: number
- gotrue_id: string
- id: number
- is_alpha_user?: boolean
- last_name?: string
- mobile?: string
- primary_email: string
- username?: string
- }
IntegrationConnectionVercel: {
foreign_project_id: string
metadata: Record<string, never>
@@ -5659,30 +5633,11 @@ export interface components {
}
TaxId: {
country: string
- id: string
type: string
value: string
}
TaxIdResponse: {
- data: components['schemas']['TaxId'][]
- }
- TaxIdV2: {
- country: string
- type: string
- value: string
- }
- TaxIdV2Response: {
- tax_id: components['schemas']['TaxIdV2'] | null
- }
- TelemetryEventBody: {
- action: string
- category: string
- ga?: components['schemas']['GoogleAnalyticBody']
- label?: Record<string, never>
- page_location?: string
- page_referrer?: string
- page_title?: string
- value?: string
+ tax_id: components['schemas']['TaxId'] | null
}
TelemetryEventBodyV2: {
action: string
@@ -5708,21 +5663,11 @@ export interface components {
reset_organization?: boolean
reset_project?: boolean
}
- TelemetryIdentifyBody: {
- ga?: components['schemas']['GoogleAnalyticBody']
- user: components['schemas']['IdentifyUserBody']
- }
TelemetryIdentifyBodyV2: {
organization_slug?: string
project_ref?: string
user_id: string
}
- TelemetryPageBody: {
- ga?: components['schemas']['GoogleAnalyticBody']
- referrer: string
- route?: string
- title: string
- }
TelemetryPageBodyV2: {
page_title: string
page_url: string
@@ -5785,8 +5730,6 @@ export interface components {
addon_type: components['schemas']['ProjectAddonType']
addon_variant: components['schemas']['AddonVariantId']
price_id?: string
- /** @enum {string} */
- proration_behaviour?: 'prorate_and_invoice_end_of_cycle' | 'prorate_and_invoice_now'
skip_outstanding_invoice_check?: boolean
}
UpdateAddonBody: {
@@ -8647,27 +8590,6 @@ export interface operations {
}
}
}
- /** Deletes any upcoming subscription schedule */
- SubscriptionController_deleteSubscriptionSchedule: {
- parameters: {
- path: {
- /** @description Organization slug */
- slug: string
- }
- }
- responses: {
- 200: {
- content: never
- }
- 403: {
- content: never
- }
- /** @description Failed to delete upcoming subscription schedule */
- 500: {
- content: never
- }
- }
- }
/** Gets the Stripe customer */
CustomerController_getCustomer: {
parameters: {
@@ -9484,8 +9406,8 @@ export interface operations {
}
}
}
- /** Gets the given organization's tax IDs */
- TaxIdsController_getTaxIds: {
+ /** Gets the given organization's tax ID */
+ TaxIdsController_getTaxId: {
parameters: {
path: {
/** @description Organization slug */
@@ -9501,7 +9423,7 @@ export interface operations {
403: {
content: never
}
- /** @description Failed to retrieve the organization's tax IDs */
+ /** @description Failed to retrieve the organization's tax ID */
500: {
content: never
}
@@ -9523,35 +9445,7 @@ export interface operations {
responses: {
200: {
content: {
- 'application/json': components['schemas']['TaxIdV2Response']
- }
- }
- 403: {
- content: never
- }
- /** @description Failed to create the tax ID */
- 500: {
- content: never
- }
- }
- }
- /** Creates a tax ID for the given organization */
- TaxIdsController_createTaxId: {
- parameters: {
- path: {
- /** @description Organization slug */
- slug: string
- }
- }
- requestBody: {
- content: {
- 'application/json': components['schemas']['CreateTaxIdBody']
- }
- }
- responses: {
- 201: {
- content: {
- 'application/json': components['schemas']['CreateTaxIdResponse']
+ 'application/json': components['schemas']['TaxIdResponse']
}
}
403: {
@@ -9571,13 +9465,8 @@ export interface operations {
slug: string
}
}
- requestBody: {
- content: {
- 'application/json': components['schemas']['DeleteTaxIdBody']
- }
- }
responses: {
- 200: {
+ 204: {
content: never
}
403: {
@@ -12016,6 +11905,27 @@ export interface operations {
}
}
}
+ /** Parses a warehouse query */
+ 'v1-parse-warehouse-query': {
+ parameters: {
+ path: {
+ /** @description Project ref */
+ ref: string
+ }
+ }
+ responses: {
+ 200: {
+ content: never
+ }
+ 403: {
+ content: never
+ }
+ /** @description Failed to parse warehouse query */
+ 500: {
+ content: never
+ }
+ }
+ }
/** Gets project's warehouse tenant from logflare */
'v1-provision-a-warehouse-tenant': {
parameters: {