Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(error-tracking): add /source-maps-key short link for a source map upload key (#120920)

Aleksander Błaszkiewiczaec8d446cee1
diff --git a/frontend/src/scenes/sceneLogic.test.tsx b/frontend/src/scenes/sceneLogic.test.tsx
index 6a6216dd8899..cb31569777b0 100644
--- a/frontend/src/scenes/sceneLogic.test.tsx
+++ b/frontend/src/scenes/sceneLogic.test.tsx
@@ -253,6 +253,13 @@ describe('sceneLogic', () => {
expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(urls.billingAuthorizationStatus())
})
+ it('sends the /source-maps-key short link to a new key with the source map upload preset', async () => {
+ router.actions.push('/source-maps-key')
+ await expectLogic(logic).delay(1)
+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(urls.settings('user-api-keys'))
+ expect(router.values.searchParams).toEqual({ preset: 'source_map_upload' })
+ })
+
it.each([
['/organization', urls.settings('organization'), Scene.Settings],
['/organization/projects', urls.settings('organization'), Scene.Settings],
diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.ts
index 08da2e8bb33f..4ab9f7998a98 100644
--- a/frontend/src/scenes/scenes.ts
+++ b/frontend/src/scenes/scenes.ts
@@ -668,6 +668,8 @@ export const redirects: Record<
},
'/web/ai-search': urls.webAnalyticsPagePerformance(),
+ // A short link to share. It opens a new personal API key with the source map upload scopes filled in.
+ '/source-maps-key': combineUrl(urls.settings('user-api-keys'), { preset: 'source_map_upload' }).url,
'/events': urls.activity(),
'/events/:id/*': ({ id, _ }, { event }) => {
const query = getEventLookupQuery(id)
diff --git a/frontend/src/scenes/settings/user/personalAPIKeysLogic.test.ts b/frontend/src/scenes/settings/user/personalAPIKeysLogic.test.ts
index b4f74fea1328..148484b0efd6 100644
--- a/frontend/src/scenes/settings/user/personalAPIKeysLogic.test.ts
+++ b/frontend/src/scenes/settings/user/personalAPIKeysLogic.test.ts
@@ -1,9 +1,11 @@
import { MOCK_DEFAULT_USER } from 'lib/api.mock'
+import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { themeLogic } from '~/layout/navigation-3000/themeLogic'
@@ -110,6 +112,16 @@ describe('personalAPIKeysLogic', () => {
expect(capturedCreatePayload.scopes).toEqual(['*'])
})
+ it('opens a new key with the preset scopes for a ?preset= link', () => {
+ router.actions.push(urls.settings('user-api-keys'), { preset: 'source_map_upload' })
+
+ expect(logic.values.editingKeyId).toBe('new')
+ expect(logic.values.editingKey).toMatchObject({
+ preset: 'source_map_upload',
+ scopes: ['organization:read', 'error_tracking:write'],
+ })
+ })
+
it.each(['survey', 'early_access_feature'])(
'auto-selects feature_flag:write when %s write is granted',
async (scope) => {