The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: Add org slug and project ref as tags to the Sentry data (#47442)
Ivan Vasilovfae2c5b96e19
diff --git a/apps/studio/lib/telemetry.test.tsx b/apps/studio/lib/telemetry.test.tsxindex 5fba56af9bf..3537b94fab4 100644--- a/apps/studio/lib/telemetry.test.tsx+++ b/apps/studio/lib/telemetry.test.tsx@@ -8,6 +8,7 @@ const mocks = vi.hoisted(() => ({useUser: vi.fn(),useOrganizationsQuery: vi.fn(),setUser: vi.fn(),+ setTag: vi.fn(),}))vi.mock('common', async (importOriginal) => {@@ -36,6 +37,7 @@ vi.mock('@/hooks/misc/useSelectedOrganization', () => ({vi.mock('@sentry/nextjs', () => ({setUser: (...args: unknown[]) => mocks.setUser(...args),+ setTag: (...args: unknown[]) => mocks.setTag(...args),}))const USER_ID = 'user-abc-123'@@ -50,6 +52,7 @@ describe('Telemetry — posthog identify mirroring', () => {mocks.useUser.mockReset()mocks.useOrganizationsQuery.mockReset()mocks.setUser.mockReset()+ mocks.setTag.mockReset()})it('fires identify with both org_count and signup_timestamp when user and orgs are loaded', async () => {diff --git a/apps/studio/lib/telemetry.tsx b/apps/studio/lib/telemetry.tsxindex ebad3e51def..cdf1a5b1c00 100644--- a/apps/studio/lib/telemetry.tsx+++ b/apps/studio/lib/telemetry.tsx@@ -1,5 +1,5 @@import * as Sentry from '@sentry/nextjs'-import { PageTelemetry, posthogClient, useUser } from 'common'+import { PageTelemetry, posthogClient, useParams, useUser } from 'common'import { useEffect, useRef } from 'react'import { useConsentToast } from 'ui-patterns/consent'@@ -19,6 +19,9 @@ export function Telemetry() {const user = useUser()+ // Project ref from the URL params, mirroring the backend's `request.params.ref`+ const { ref: projectRef } = useParams()+// Mirror the user's org-list length into a PostHog person property so feature// flags and analytics can segment by current org membership. signup_timestamp// is set on the same identify so flag audiences requiring both properties see@@ -50,12 +53,16 @@ export function Telemetry() {useEffect(() => {// don't set the sentry user id if the user hasn't logged in (so that Sentry errors show null user id instead of anonymous id)- if (!user?.id) {- return+ if (user?.id) {+ Sentry.setUser({ id: user.id })}- Sentry.setUser({ id: user.id })- }, [user?.id])+ // Tag Sentry events with the current project ref and customer org slug so backend/+ // frontend errors can be filtered by project / org. Passing a null value clears+ // the tag, so stale values don't leak across navigation.+ Sentry.setTag('project_ref', projectRef ?? null)+ Sentry.setTag('org_slug', organization?.slug ?? null)+ }, [user?.id, projectRef, organization?.slug])return (<PageTelemetry