Skip to content

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

fix(studio): track resourceAccess='account' for legacy access tokens (#49448)

claude[bot]c32db2b80bec
diff --git a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.test.tsx b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.test.tsx
index 811cc1f20e4..1b4c3072a2c 100644
--- a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.test.tsx
+++ b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.test.tsx
@@ -21,6 +21,9 @@ vi.mock('common', async (importOriginal) => {
return { ...actual, useReducedMotion: () => mockUseReducedMotion() }
})
+const { mockTrack } = vi.hoisted(() => ({ mockTrack: vi.fn() }))
+vi.mock('@/lib/telemetry/track', () => ({ useTrack: () => mockTrack }))
+
const user = userEvent.setup({
writeToClipboard: true,
})
@@ -138,6 +141,7 @@ describe('NewScopedTokenSheet', () => {
})
beforeEach(() => {
+ mockTrack.mockReset()
mockPermissionsMap()
mockOrganizations()
mockProjects()
@@ -416,6 +420,12 @@ describe('NewScopedTokenSheet', () => {
await waitFor(async () =>
expect(await window.navigator.clipboard.readText()).toEqual('a_classic_token_value')
)
+ // resourceAccess must be tracked as 'account' — it is the only path that emits that value
+ expect(mockTrack).toHaveBeenCalledWith('access_token_created', {
+ tokenType: 'classic',
+ expiryPreset: '7d',
+ resourceAccess: 'account',
+ })
fireEvent.click(await screen.findByLabelText('I have copied the key and stored it securely'))
fireEvent.click(await screen.findByRole('button', { name: 'Done' }))
// Dialog has been closed
diff --git a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx
index 21fb38c3af0..302388d8060 100644
--- a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx
+++ b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx
@@ -63,6 +63,7 @@ export const NewScopedTokenSheet = ({ onCreateExperimentalToken }: NewScopedToke
track('access_token_created', {
tokenType: 'classic',
expiryPreset: values.expiresAt,
+ resourceAccess: 'account',
})
showCreatedToken(data)
},