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.

fix(devex): build ApiRequest team paths on the canonical projects route (#104229)

Julian Beze2c7dc64eb69
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 9bd7608d4fe6..10024e9f076c 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7737,9 +7737,9 @@ snapshots:
scenes-app-data-pipelines-destinations--realtime--light:
hash: v1.k794b7964.90a104b79843b4b06635df7d85ccd0549df8f0b9a4971afea09f374c05bcd010.E9MSjaXn9JMVTj-quN955urarkj2H7a3oVXuHooUd50
scenes-app-data-pipelines-destinations-incident-replay-banner--default--dark:
- hash: v1.k794b7964.e6d0767c743d29188c9e2cd7cda13c4ae2580e323fc61298dd749c2ada6748ce.hsLdEbmZBzM5ytotm0trAusUL8v0kk9mrHCvtLDleDk
+ hash: v1.k794b7964.180cab2c6184f778ee72521bfd3776004d62c8fa7d822ae91a7af06d1ab12111.LmUCiAt2EBpkwhT4s3chjsCdq4JD3V_b2HeDkKSnifw
scenes-app-data-pipelines-destinations-incident-replay-banner--default--light:
- hash: v1.k794b7964.9470c6fd30bf7a37caf55d61d73a8b2e4fc52c95634c18832212f7e8470a27b7.hdLajs9Vv1linws_5FrgcdRjMWpzk4_8SnDzkWz9z64
+ hash: v1.k794b7964.68aae054d71cc2b3f9fa5cf6e2f341f23bbff3057a67d8aa1491c057b127050e.ZzeUlB7VWX3jhleoby_01IQMZePDlv9netuwDg7nnY8
scenes-app-data-pipelines-event-filtering--add-condition-and-test-case--dark:
hash: v1.k794b7964.054b485fa44909bda3f635ba9d134cea4dfa7e60bbc65206ba752f23b7729c42._2cxQzZ_XmaTvoI9Z7hIKh5kpuDY5rxQG0-1RNRyDgE
scenes-app-data-pipelines-event-filtering--add-condition-and-test-case--light:
@@ -9543,7 +9543,7 @@ snapshots:
scenes-app-mcp-analytics--sessions--dark:
hash: v1.k794b7964.a66e676a524e1de75d68579adb63b097fc17ed5db94ca86dccbf9e6265b169ac.sVkiD6KMNejyrVPs1hOZjHQWspPL2a7lvOWA6VcPNps
scenes-app-mcp-analytics--sessions--light:
- hash: v1.k794b7964.16f1771f05843a7492f213219e671ca1f8ab3c6ca03e49af7f47e13e40525585.p72ZdNHtERLOxua-BOsZX5tyg9fPU2-1h_VSEr7aaGw
+ hash: v1.k794b7964.17f5e27f60024ff6e083bc6b799427b40e475fddb3bf7900aaab5f935d509b23.cgze06ZKpLRtg_doPvcuWuj_yfLplR3PlkqRGeqxzfE
scenes-app-mcp-analytics--tool-quality--dark:
hash: v1.k794b7964.697b42ee7e043ae0dd4bf56ffcab59f24810196459f4303be1a418ed8e0f128d.hxsxWCzwdJI2stSHMmN6oMhjhsnPtB4iv8_OJxgzScs
scenes-app-mcp-analytics--tool-quality--light:
diff --git a/frontend/src/lib/api.test.ts b/frontend/src/lib/api.test.ts
index 61adffdbdfa4..468d7c83581c 100644
--- a/frontend/src/lib/api.test.ts
+++ b/frontend/src/lib/api.test.ts
@@ -51,7 +51,7 @@ describe('API helper', () => {
)
expect(fakeFetch).toHaveBeenCalledWith(
- '/api/environments/2/events?properties=%5B%7B%22key%22%3A%22something%22%2C%22value%22%3A%22is_set%22%2C%22operator%22%3A%22is_set%22%2C%22type%22%3A%22event%22%7D%5D&limit=10&orderBy=%5B%22-timestamp%22%5D',
+ '/api/projects/2/events?properties=%5B%7B%22key%22%3A%22something%22%2C%22value%22%3A%22is_set%22%2C%22operator%22%3A%22is_set%22%2C%22type%22%3A%22event%22%7D%5D&limit=10&orderBy=%5B%22-timestamp%22%5D',
{
signal: undefined,
headers: {
@@ -144,7 +144,7 @@ describe('API helper', () => {
it('adds query kind to the query URL when present', async () => {
await api.query({ kind: NodeKind.HogQLQuery, query: 'select 1' })
- expect(fakeFetch.mock.calls[0][0]).toEqual('/api/environments/2/query/HogQLQuery/')
+ expect(fakeFetch.mock.calls[0][0]).toEqual('/api/projects/2/query/HogQLQuery/')
})
it('uses the accounts table endpoint for AccountsTableQuery', async () => {
@@ -157,7 +157,7 @@ describe('API helper', () => {
it('keeps the query URL kind optional', async () => {
await api.query({} as Record<string, any>)
- expect(fakeFetch.mock.calls[0][0]).toEqual('/api/environments/2/query/')
+ expect(fakeFetch.mock.calls[0][0]).toEqual('/api/projects/2/query/')
})
it('throws when the query URL kind does not match the request body', async () => {
@@ -179,23 +179,23 @@ describe('API helper', () => {
[
'hogFlows.updateHogFlow',
() => api.hogFlows.updateHogFlow('flow-1', {}),
- '/api/environments/2/hog_flows/flow-1/',
+ '/api/projects/2/hog_flows/flow-1/',
],
- ['hogFlows.createHogFlow', () => api.hogFlows.createHogFlow({}), '/api/environments/2/hog_flows/'],
+ ['hogFlows.createHogFlow', () => api.hogFlows.createHogFlow({}), '/api/projects/2/hog_flows/'],
[
'messaging.updateTemplate',
() => api.messaging.updateTemplate('template-1', {}),
- '/api/environments/2/messaging_templates/template-1/',
+ '/api/projects/2/messaging_templates/template-1/',
],
[
'messaging.getCategory',
() => api.messaging.getCategory('category-1'),
- '/api/environments/2/messaging_categories/category-1/',
+ '/api/projects/2/messaging_categories/category-1/',
],
[
'messaging.generateMessagingPreferencesLink',
() => api.messaging.generateMessagingPreferencesLink(),
- '/api/environments/2/messaging_preferences/generate_link/',
+ '/api/projects/2/messaging_preferences/generate_link/',
],
])("%s targets the tab's team, not @current", async (_name, request, expected) => {
await request()
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index ca70853aa511..b7fc66d84460 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -581,30 +581,28 @@ export class ApiRequest {
return this.projects().addPathComponent(id)
}
- // # Environments
- public environments(): ApiRequest {
- return this.addPathComponent('environments')
- }
-
- public environmentsDetail(id: TeamType['id'] = ApiConfig.getCurrentTeamId()): ApiRequest {
- return this.environments().addPathComponent(id)
+ // The deprecated environments alias is one EnvironmentsRewriteMiddleware rewrites to the projects
+ // viewset, so team-scoped paths build on `projects/` instead. The id stays the team id, because a
+ // child environment has a different id from its project and the route accepts either.
+ public teamProjectDetail(id: TeamType['id'] = ApiConfig.getCurrentTeamId()): ApiRequest {
+ return this.projectsDetail(id)
}
// # CSP reporting
public cspReportingExplanation(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('csp-reporting').addPathComponent('explain')
+ return this.teamProjectDetail(teamId).addPathComponent('csp-reporting').addPathComponent('explain')
}
// # AI observability
public aiObservabilityTranslate(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('llm_analytics').addPathComponent('translate')
+ return this.teamProjectDetail(teamId).addPathComponent('llm_analytics').addPathComponent('translate')
}
// # Insights
public insights(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('insights')
+ return this.teamProjectDetail(teamId).addPathComponent('insights')
}
public insight(id: QueryBasedInsightModel['id'], teamId?: TeamType['id']): ApiRequest {
@@ -637,7 +635,7 @@ export class ApiRequest {
// # Column Configurations
public columnConfigurations(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('column_configurations')
+ return this.teamProjectDetail(teamId).addPathComponent('column_configurations')
}
public columnConfigurationDetail(id: string, teamId?: TeamType['id']): ApiRequest {
@@ -651,7 +649,7 @@ export class ApiRequest {
// (used by a different app, not this frontend) serve the "desktop" surface. So every call
// from this frontend is implicitly and exclusively scoped to "web".
public fileSystem(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('file_system')
+ return this.teamProjectDetail(teamId).addPathComponent('file_system')
}
public fileSystemUnfiled(type?: string, teamId?: TeamType['id']): ApiRequest {
@@ -687,7 +685,7 @@ export class ApiRequest {
}
public fileSystemShortcut(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('file_system_shortcut')
+ return this.teamProjectDetail(teamId).addPathComponent('file_system_shortcut')
}
public fileSystemShortcutDetail(id: NonNullable<FileSystemEntry['id']>, teamId?: TeamType['id']): ApiRequest {
@@ -700,7 +698,7 @@ export class ApiRequest {
// # User product list
public userProductList(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('user_product_list')
+ return this.teamProjectDetail(teamId).addPathComponent('user_product_list')
}
// # Plugins
@@ -713,7 +711,7 @@ export class ApiRequest {
}
public pluginConfigs(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('plugin_configs')
+ return this.teamProjectDetail(teamId).addPathComponent('plugin_configs')
}
public pluginConfig(id: number, teamId?: TeamType['id']): ApiRequest {
@@ -729,7 +727,7 @@ export class ApiRequest {
}
public hogFunctions(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('hog_functions')
+ return this.teamProjectDetail(teamId).addPathComponent('hog_functions')
}
public hogFunction(id: HogFunctionType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -755,11 +753,11 @@ export class ApiRequest {
// # MCP Store
public mcpServers(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('mcp_servers')
+ return this.teamProjectDetail(teamId).addPathComponent('mcp_servers')
}
public mcpServerInstallations(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('mcp_server_installations')
+ return this.teamProjectDetail(teamId).addPathComponent('mcp_server_installations')
}
public mcpServerInstallation(id: string, teamId?: TeamType['id']): ApiRequest {
@@ -786,7 +784,7 @@ export class ApiRequest {
// # Exports
public exports(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('exports')
+ return this.teamProjectDetail(teamId).addPathComponent('exports')
}
public export(id: number, teamId?: TeamType['id']): ApiRequest {
@@ -795,7 +793,7 @@ export class ApiRequest {
// # Events
public events(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('events')
+ return this.teamProjectDetail(teamId).addPathComponent('events')
}
public event(id: EventType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -808,7 +806,7 @@ export class ApiRequest {
// # Logs
public logs(projectId?: ProjectType['id']): ApiRequest {
- return this.environmentsDetail(projectId).addPathComponent('logs')
+ return this.teamProjectDetail(projectId).addPathComponent('logs')
}
public logsQuery(projectId?: ProjectType['id']): ApiRequest {
@@ -833,7 +831,7 @@ export class ApiRequest {
// # Tracing
public tracingSpans(): ApiRequest {
- return this.environmentsDetail().addPathComponent('tracing').addPathComponent('spans')
+ return this.teamProjectDetail().addPathComponent('tracing').addPathComponent('spans')
}
// # Data management
@@ -930,7 +928,7 @@ export class ApiRequest {
// # Customer Profile Configs
public customerProfileConfigs(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('customer_profile_configs')
+ return this.teamProjectDetail(teamId).addPathComponent('customer_profile_configs')
}
public customerProfileConfigsDetail(id: CustomerProfileConfigType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -938,7 +936,7 @@ export class ApiRequest {
}
public customerJourneys(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('customer_journeys')
+ return this.teamProjectDetail(teamId).addPathComponent('customer_journeys')
}
public customerJourneysDetail(id: CustomerJourneyApi['id'], teamId?: TeamType['id']): ApiRequest {
@@ -947,7 +945,7 @@ export class ApiRequest {
// Recordings
public recordings(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('session_recordings')
+ return this.teamProjectDetail(teamId).addPathComponent('session_recordings')
}
public recording(recordingId: SessionRecordingType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -955,13 +953,11 @@ export class ApiRequest {
}
public sessionRecordingsExternalReferences(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('session_recording_external_references')
+ return this.teamProjectDetail(teamId).addPathComponent('session_recording_external_references')
}
public recordingMatchingEvents(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId)
- .addPathComponent('session_recordings')
- .addPathComponent('matching_events')
+ return this.teamProjectDetail(teamId).addPathComponent('session_recordings').addPathComponent('matching_events')
}
public recordingPlaylists(teamId?: TeamType['id']): ApiRequest {
@@ -995,7 +991,7 @@ export class ApiRequest {
// # Dashboards
public dashboards(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('dashboards')
+ return this.teamProjectDetail(teamId).addPathComponent('dashboards')
}
public dashboardsDetail(dashboardId: DashboardType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1118,7 +1114,7 @@ export class ApiRequest {
// # Persons
public persons(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('persons')
+ return this.teamProjectDetail(teamId).addPathComponent('persons')
}
public person(id: string | number, teamId?: TeamType['id']): ApiRequest {
@@ -1134,7 +1130,7 @@ export class ApiRequest {
// # Groups
public groups(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('groups')
+ return this.teamProjectDetail(teamId).addPathComponent('groups')
}
public group(index: number, key: string, teamId?: TeamType['id']): ApiRequest {
@@ -1230,7 +1226,7 @@ export class ApiRequest {
// # User interviews
public userInterviews(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('user_interviews')
+ return this.teamProjectDetail(teamId).addPathComponent('user_interviews')
}
public userInterview(id: UserInterviewType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1342,7 +1338,7 @@ export class ApiRequest {
// Error tracking
public errorTracking(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('error_tracking')
+ return this.teamProjectDetail(teamId).addPathComponent('error_tracking')
}
public errorTrackingIssues(teamId?: TeamType['id']): ApiRequest {
@@ -1402,7 +1398,7 @@ export class ApiRequest {
}
public gitProviderFileLinks(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId)
+ return this.teamProjectDetail(teamId)
.addPathComponent('error_tracking')
.addPathComponent('git-provider-file-links')
}
@@ -1448,7 +1444,7 @@ export class ApiRequest {
}
public quickFilters(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('quick_filters')
+ return this.teamProjectDetail(teamId).addPathComponent('quick_filters')
}
public quickFilter(id: string, teamId?: TeamType['id']): ApiRequest {
@@ -1457,7 +1453,7 @@ export class ApiRequest {
// # Web Analytics Filter Presets
public webAnalyticsFilterPresets(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('web_analytics_filter_presets')
+ return this.teamProjectDetail(teamId).addPathComponent('web_analytics_filter_presets')
}
public webAnalyticsFilterPreset(shortId: string, teamId?: TeamType['id']): ApiRequest {
@@ -1466,7 +1462,7 @@ export class ApiRequest {
// # Warehouse
public dataWarehouseTables(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('warehouse_tables')
+ return this.teamProjectDetail(teamId).addPathComponent('warehouse_tables')
}
public dataWarehouseTable(id: DataWarehouseTable['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1475,11 +1471,11 @@ export class ApiRequest {
// # Warehouse view
public dataWarehouseSavedQueries(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('warehouse_saved_queries')
+ return this.teamProjectDetail(teamId).addPathComponent('warehouse_saved_queries')
}
public dataWarehouseSavedQueryFolders(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('warehouse_saved_query_folders')
+ return this.teamProjectDetail(teamId).addPathComponent('warehouse_saved_query_folders')
}
public dataWarehouseSavedQuery(id: DataWarehouseSavedQuery['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1491,7 +1487,7 @@ export class ApiRequest {
}
public dataWarehouseSavedQueryDrafts(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('warehouse_saved_query_drafts')
+ return this.teamProjectDetail(teamId).addPathComponent('warehouse_saved_query_drafts')
}
public dataWarehouseSavedQueryDraft(id: DataWarehouseSavedQueryDraft['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1509,7 +1505,7 @@ export class ApiRequest {
offset = 0,
teamId?: TeamType['id']
): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('data_modeling_jobs').withQueryString({
+ return this.teamProjectDetail(teamId).addPathComponent('data_modeling_jobs').withQueryString({
saved_query_id: savedQueryId,
limit: pageSize,
offset,
@@ -1517,16 +1513,16 @@ export class ApiRequest {
}
public dataModelingJobsRunning(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('data_modeling_jobs').addPathComponent('running')
+ return this.teamProjectDetail(teamId).addPathComponent('data_modeling_jobs').addPathComponent('running')
}
public dataModelingJobsRecent(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('data_modeling_jobs').addPathComponent('recent')
+ return this.teamProjectDetail(teamId).addPathComponent('data_modeling_jobs').addPathComponent('recent')
}
// # Data Modeling Nodes
public dataModelingNodes(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('data_modeling_nodes')
+ return this.teamProjectDetail(teamId).addPathComponent('data_modeling_nodes')
}
public dataModelingNode(id: DataModelingNode['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1535,12 +1531,12 @@ export class ApiRequest {
// # Data Modeling Edges
public dataModelingEdges(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('data_modeling_edges')
+ return this.teamProjectDetail(teamId).addPathComponent('data_modeling_edges')
}
// # Warehouse view link
public dataWarehouseViewLinks(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('warehouse_view_link')
+ return this.teamProjectDetail(teamId).addPathComponent('warehouse_view_link')
}
public dataWarehouseViewLink(id: DataWarehouseViewLink['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1562,7 +1558,7 @@ export class ApiRequest {
// # Subscriptions
public subscriptions(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('subscriptions')
+ return this.teamProjectDetail(teamId).addPathComponent('subscriptions')
}
public subscription(id: SubscriptionType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1571,7 +1567,7 @@ export class ApiRequest {
// # Integrations
public integrations(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('integrations')
+ return this.teamProjectDetail(teamId).addPathComponent('integrations')
}
public integration(id: IntegrationType['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1717,15 +1713,12 @@ export class ApiRequest {
// # Alerts
public alerts(alertId?: AlertType['id'], insightId?: InsightModel['id'], teamId?: TeamType['id']): ApiRequest {
if (alertId) {
- return this.environmentsDetail(teamId)
- .addPathComponent('alerts')
- .addPathComponent(alertId)
- .withQueryString({
- insight_id: insightId,
- })
+ return this.teamProjectDetail(teamId).addPathComponent('alerts').addPathComponent(alertId).withQueryString({
+ insight_id: insightId,
+ })
}
- return this.environmentsDetail(teamId).addPathComponent('alerts').withQueryString({
+ return this.teamProjectDetail(teamId).addPathComponent('alerts').withQueryString({
insight_id: insightId,
})
}
@@ -1742,7 +1735,7 @@ export class ApiRequest {
// Queries
public query(teamId?: TeamType['id'], queryKind?: string): ApiRequest {
- const apiRequest = this.environmentsDetail(teamId).addPathComponent('query')
+ const apiRequest = this.teamProjectDetail(teamId).addPathComponent('query')
if (queryKind) {
return apiRequest.addPathComponent(queryKind)
}
@@ -1762,7 +1755,7 @@ export class ApiRequest {
}
public queryUpgrade(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('query').addPathComponent('upgrade')
+ return this.teamProjectDetail(teamId).addPathComponent('query').addPathComponent('upgrade')
}
public queryLog(queryId: string, teamId?: TeamType['id']): ApiRequest {
@@ -1779,7 +1772,7 @@ export class ApiRequest {
// Endpoints
public endpoint(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('endpoints')
+ return this.teamProjectDetail(teamId).addPathComponent('endpoints')
}
public endpointDetail(name: string): ApiRequest {
@@ -1792,21 +1785,21 @@ export class ApiRequest {
// Managed Viewsets
public dataWarehouseManagedViewset(kind: DataWarehouseManagedViewsetKind, teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('managed_viewsets').addPathComponent(kind)
+ return this.teamProjectDetail(teamId).addPathComponent('managed_viewsets').addPathComponent(kind)
}
// Conversations (Max AI)
public conversations(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('conversations')
+ return this.teamProjectDetail(teamId).addPathComponent('conversations')
}
public conversation(id: string, teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('conversations').addPathComponent(id)
+ return this.teamProjectDetail(teamId).addPathComponent('conversations').addPathComponent(id)
}
// Max hands-free mode (ElevenLabs Scribe token proxy)
public maxHandsFree(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('max_hands_free')
+ return this.teamProjectDetail(teamId).addPathComponent('max_hands_free')
}
// Conversations (Support product)
@@ -1829,7 +1822,7 @@ export class ApiRequest {
// Batch Exports
public batchExports(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('batch_exports')
+ return this.teamProjectDetail(teamId).addPathComponent('batch_exports')
}
public batchExport(id: BatchExportConfiguration['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1862,7 +1855,7 @@ export class ApiRequest {
// External Data Source
public externalDataSources(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('external_data_sources')
+ return this.teamProjectDetail(teamId).addPathComponent('external_data_sources')
}
public externalDataSource(sourceId: ExternalDataSource['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1870,7 +1863,7 @@ export class ApiRequest {
}
public externalDataSchemas(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('external_data_schemas')
+ return this.teamProjectDetail(teamId).addPathComponent('external_data_schemas')
}
public externalDataSourceSchema(schemaId: ExternalDataSourceSchema['id'], teamId?: TeamType['id']): ApiRequest {
@@ -1886,12 +1879,12 @@ export class ApiRequest {
// Fix HogQL errors
public fixHogQLErrors(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('fix_hogql')
+ return this.teamProjectDetail(teamId).addPathComponent('fix_hogql')
}
// Insight Variables
public insightVariables(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('insight_variables')
+ return this.teamProjectDetail(teamId).addPathComponent('insight_variables')
}
public insightVariable(variableId: string, teamId?: TeamType['id']): ApiRequest {
@@ -1948,20 +1941,20 @@ export class ApiRequest {
// Data color themes
public dataColorThemes(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('data_color_themes')
+ return this.teamProjectDetail(teamId).addPathComponent('data_color_themes')
}
public dataColorTheme(id: DataColorThemeModel['id'], teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('data_color_themes').addPathComponent(id)
+ return this.teamProjectDetail(teamId).addPathComponent('data_color_themes').addPathComponent(id)
}
public addProductIntent(): ApiRequest {
- return this.environments().current().addPathComponent('add_product_intent')
+ return this.projects().current().addPathComponent('add_product_intent')
}
// Max Core Memory
public coreMemory(): ApiRequest {
- return this.environmentsDetail().addPathComponent('core_memory')
+ return this.teamProjectDetail().addPathComponent('core_memory')
}
public coreMemoryDetail(id: CoreMemory['id']): ApiRequest {
@@ -1969,7 +1962,7 @@ export class ApiRequest {
}
public messagingTemplates(): ApiRequest {
- return this.environmentsDetail().addPathComponent('messaging_templates')
+ return this.teamProjectDetail().addPathComponent('messaging_templates')
}
public messagingTemplate(templateId: MessageTemplate['id']): ApiRequest {
@@ -1977,7 +1970,7 @@ export class ApiRequest {
}
public messagingCategories(): ApiRequest {
- return this.environmentsDetail().addPathComponent('messaging_categories')
+ return this.teamProjectDetail().addPathComponent('messaging_categories')
}
public messagingCategory(categoryId: string): ApiRequest {
@@ -2013,7 +2006,7 @@ export class ApiRequest {
}
public messagingPreferences(): ApiRequest {
- return this.environmentsDetail().addPathComponent('messaging_preferences')
+ return this.teamProjectDetail().addPathComponent('messaging_preferences')
}
public messagingPreferencesLink(): ApiRequest {
@@ -2029,7 +2022,7 @@ export class ApiRequest {
}
public hogFlows(): ApiRequest {
- return this.environmentsDetail().addPathComponent('hog_flows')
+ return this.teamProjectDetail().addPathComponent('hog_flows')
}
public hogFlow(hogFlowId: HogFlow['id']): ApiRequest {
@@ -2037,7 +2030,7 @@ export class ApiRequest {
}
public hogFlowTemplates(): ApiRequest {
- return this.environmentsDetail().addPathComponent('hog_flow_templates')
+ return this.teamProjectDetail().addPathComponent('hog_flow_templates')
}
public hogFlowTemplate(hogFlowTemplateId: HogFlowTemplate['id']): ApiRequest {
@@ -2045,12 +2038,12 @@ export class ApiRequest {
}
public evaluationRuns(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('evaluation_runs')
+ return this.teamProjectDetail(teamId).addPathComponent('evaluation_runs')
}
// Heatmap screenshots
public heatmapScreenshots(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('heatmap_screenshots')
+ return this.teamProjectDetail(teamId).addPathComponent('heatmap_screenshots')
}
public heatmapScreenshot(id: number, teamId?: TeamType['id']): ApiRequest {
@@ -2059,7 +2052,7 @@ export class ApiRequest {
public heatmapScreenshotsSaved(teamId?: TeamType['id']): ApiRequest {
// Deprecated path: kept for potential fallback during rollout
- return this.environmentsDetail(teamId).addPathComponent('saved')
+ return this.teamProjectDetail(teamId).addPathComponent('saved')
}
public heatmapScreenshotSaved(id: number | string, teamId?: TeamType['id']): ApiRequest {
@@ -2068,7 +2061,7 @@ export class ApiRequest {
// Revenue analytics
public revenueAnalyticsJoins(teamId?: TeamType['id']): ApiRequest {
- return this.environmentsDetail(teamId).addPathComponent('revenue_analytics').addPathComponent('joins')
+ return this.teamProjectDetail(teamId).addPathComponent('revenue_analytics').addPathComponent('joins')
}
}
@@ -6534,7 +6527,7 @@ const api = {
...(scope !== undefined ? { scope } : {}),
}
return await new ApiRequest()
- .environments()
+ .projects()
.current()
.withAction('settings_as_of')
.withQueryString(toParams(params, true))
@@ -7424,7 +7417,7 @@ const api = {
projects: {
async generateConversationsPublicToken(teamId?: TeamType['id']): Promise<TeamType> {
return await new ApiRequest()
- .environmentsDetail(teamId)
+ .teamProjectDetail(teamId)
.withAction('generate_conversations_public_token')
.create()
},
diff --git a/frontend/src/lib/components/ExportButton/exporter.test.ts b/frontend/src/lib/components/ExportButton/exporter.test.ts
index 2662c3097d8a..255831e60ca0 100644
--- a/frontend/src/lib/components/ExportButton/exporter.test.ts
+++ b/frontend/src/lib/components/ExportButton/exporter.test.ts
@@ -45,7 +45,7 @@ describe('exporter', () => {
// The click must fire synchronously with no await before it (no preflight fetch), or Safari
// drops the download once the user gesture expires.
expect(getResponse).not.toHaveBeenCalled()
- expect((fakeAnchor as any).href).toBe('/api/environments/1/exports/123/content?download=true')
+ expect((fakeAnchor as any).href).toBe('/api/projects/1/exports/123/content?download=true')
expect((fakeAnchor as any).click).toHaveBeenCalled()
expect(appendSpy).toHaveBeenCalledWith(fakeAnchor)
@@ -60,6 +60,6 @@ describe('exporter', () => {
await exportedAssetBlob({ id: 123 } as ExportedAssetType)
- expect(getResponse).toHaveBeenCalledWith('/api/environments/1/exports/123/content?direct=true')
+ expect(getResponse).toHaveBeenCalledWith('/api/projects/1/exports/123/content?direct=true')
})
})
diff --git a/frontend/src/scenes/data-management/events/eventDefinitionsTableLogic.test.ts b/frontend/src/scenes/data-management/events/eventDefinitionsTableLogic.test.ts
index 746982b23155..624916fbd64e 100644
--- a/frontend/src/scenes/data-management/events/eventDefinitionsTableLogic.test.ts
+++ b/frontend/src/scenes/data-management/events/eventDefinitionsTableLogic.test.ts
@@ -273,14 +273,14 @@ describe('eventDefinitionsTableLogic', () => {
[propertiesStartingUrl]: expect.objectContaining({
count: 5,
}),
- [`api/environments/${MOCK_TEAM_ID}/events?event=event1&limit=1`]: expect.objectContaining(
+ [`api/projects/${MOCK_TEAM_ID}/events?event=event1&limit=1`]: expect.objectContaining(
mockEvent.properties
),
})
expect(api.get).toHaveBeenCalledTimes(3)
expect(api.get).toHaveBeenNthCalledWith(1, propertiesStartingUrl)
- expect(api.get).toHaveBeenNthCalledWith(2, `api/environments/${MOCK_TEAM_ID}/events?event=event1&limit=1`)
+ expect(api.get).toHaveBeenNthCalledWith(2, `api/projects/${MOCK_TEAM_ID}/events?event=event1&limit=1`)
expect(api.get).toHaveBeenNthCalledWith(3, startingUrl)
await expectLogic(logic, () => {
diff --git a/frontend/src/scenes/insights/insightLogic.test.ts b/frontend/src/scenes/insights/insightLogic.test.ts
index d9a2d911f647..83048e309f69 100644
--- a/frontend/src/scenes/insights/insightLogic.test.ts
+++ b/frontend/src/scenes/insights/insightLogic.test.ts
@@ -270,10 +270,6 @@ describe('insightLogic', () => {
)
return [200, response]
},
- '/api/projects/:team/insights/:id': async ({ request, params }) => {
- const payload = (await request.json()) as Record<string, any>
- return [200, { ...payload, id: params.id }]
- },
},
})
initKeaTests(true, { ...MOCK_DEFAULT_TEAM, test_account_filters_default_checked: true })
@@ -913,7 +909,7 @@ describe('insightLogic', () => {
const mockCreateCalls = (api.create as jest.Mock).mock.calls
expect(mockCreateCalls).toEqual([
[
- `api/environments/${MOCK_TEAM_ID}/insights`,
+ `api/projects/${MOCK_TEAM_ID}/insights`,
expect.objectContaining({
derived_name: '* from events',
query: {
diff --git a/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts b/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts
index cde6120da2d4..23e508b58412 100644
--- a/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts
+++ b/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts
@@ -322,7 +322,7 @@ describe('savedInsightsLogic', () => {
sourceInsight.derived_name = 'should be copied'
await logic.asyncActions.duplicateInsight(sourceInsight)
expect(api.create).toHaveBeenCalledWith(
- `api/environments/${MOCK_TEAM_ID}/insights`,
+ `api/projects/${MOCK_TEAM_ID}/insights`,
expect.objectContaining({ name: '' }),
expect.objectContaining({})
)
@@ -334,7 +334,7 @@ describe('savedInsightsLogic', () => {
sourceInsight.derived_name = ''
await logic.asyncActions.duplicateInsight(sourceInsight)
expect(api.create).toHaveBeenCalledWith(
- `api/environments/${MOCK_TEAM_ID}/insights`,
+ `api/projects/${MOCK_TEAM_ID}/insights`,
expect.objectContaining({ name: 'should be copied (copy)' }),
expect.objectContaining({})
)
diff --git a/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts b/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts
index ba240a031c96..75c4054a67aa 100644
--- a/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts
+++ b/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts
@@ -84,7 +84,7 @@ test.describe('Insight side panel actions', () => {
const patchPromise = page.waitForResponse(
(resp) =>
- resp.url().includes('/api/environments/') &&
+ resp.url().includes('/api/projects/') &&
resp.url().includes('/insights/') &&
resp.request().method() === 'PATCH'
)
diff --git a/products/persons/frontend/logics/personsLogic.test.ts b/products/persons/frontend/logics/personsLogic.test.ts
index c9f062c01cdb..d1e360438cb8 100644
--- a/products/persons/frontend/logics/personsLogic.test.ts
+++ b/products/persons/frontend/logics/personsLogic.test.ts
@@ -158,10 +158,7 @@ describe('personsLogic', () => {
await expectLogic(logic, () => {
logic.actions.loadPerson('+')
// has encoded from + in the action to %2B in the API call
- expect(api.get).toHaveBeenCalledWith(
- `api/environments/${MOCK_TEAM_ID}/persons?distinct_id=%2B`,
- undefined
- )
+ expect(api.get).toHaveBeenCalledWith(`api/projects/${MOCK_TEAM_ID}/persons?distinct_id=%2B`, undefined)
})
.toDispatchActions(['loadPerson', 'loadPersonSuccess'])
.toMatchValues({
diff --git a/products/replay/frontend/e2e/player.spec.ts b/products/replay/frontend/e2e/player.spec.ts
index 3809a02fa903..563338fea315 100644
--- a/products/replay/frontend/e2e/player.spec.ts
+++ b/products/replay/frontend/e2e/player.spec.ts
@@ -125,7 +125,7 @@ function snappyBlocks(texts: string[]): Buffer {
async function mockRecordingApi(page: Page): Promise<void> {
for (const [sessionId, recording] of Object.entries(RECORDINGS)) {
await page.route(
- new RegExp(`/api/environments/\\d+/session_recordings/${sessionId}/snapshots/?(\\?.*)?$`),
+ new RegExp(`/api/projects/\\d+/session_recordings/${sessionId}/snapshots/?(\\?.*)?$`),
async (route) => {
const url = new URL(route.request().url())
// Content requests carry ?source=blob_v2 (+ a blob key range); listing requests don't.
@@ -164,7 +164,7 @@ async function mockRecordingApi(page: Page): Promise<void> {
})
}
)
- await page.route(new RegExp(`/api/environments/\\d+/session_recordings/${sessionId}/?(\\?.*)?$`), (route) =>
+ await page.route(new RegExp(`/api/projects/\\d+/session_recordings/${sessionId}/?(\\?.*)?$`), (route) =>
route.fulfill({ status: 200, json: recording.meta })
)
}
diff --git a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx
index 3d81d6a31a58..8276fe99ae63 100644
--- a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx
@@ -211,6 +211,19 @@ const meta: Meta<StoryArgs> = {
: INSIGHT_SUBSCRIPTIONS
const dashboardInsightSubscriptions: SubscriptionType[] = INSIGHT_SUBSCRIPTIONS
+ const listSubscriptions = ({ request }: { request: Request }): Record<string, any> => {
+ const searchParams = new URL(request.url).searchParams
+ let results = contextualSubscriptions
+
+ if (searchParams.get('resource_type') === 'ai_prompt') {
+ results = AI_PROMPT_SUBSCRIPTIONS
+ } else if (searchParams.has('dashboard_tiles')) {
+ results = dashboardInsightSubscriptions
+ }
+
+ return { count: results.length, results }
+ }
+
useStorybookMocks({
get: {
'/_preflight': {
@@ -224,25 +237,17 @@ const meta: Meta<StoryArgs> = {
...MOCK_DEFAULT_ORGANIZATION,
is_ai_data_processing_approved: true,
},
- '/api/environments/:id/subscriptions': ({ request }) => {
- const searchParams = new URL(request.url).searchParams
- let results = contextualSubscriptions
-
- if (searchParams.get('resource_type') === 'ai_prompt') {
- results = AI_PROMPT_SUBSCRIPTIONS
- } else if (searchParams.has('dashboard_tiles')) {
- results = dashboardInsightSubscriptions
- }
-
- return { count: results.length, results }
- },
+ '/api/environments/:id/subscriptions': listSubscriptions,
'/api/environments/:id/subscriptions/:subId':
formScenario === 'long-ai-prompt' ? LONG_AI_PROMPT_SUBSCRIPTION : createMockSubscription(),
'/api/projects/:id/subscriptions/:subId/deliveries': { results: [] },
- // subscriptionCountLogic counts through the generated client, which asks for the
- // projects path. Say the count every scenario means, because the contextual list
- // above is a different question and would read as a free-tier limit.
- '/api/projects/:id/subscriptions/': { count: freeTierSubscriptionCount ?? 0, results: [] },
+ // The modal's list and subscriptionCountLogic both read this path. Only the count
+ // call passes limit=1, and it drives the free-tier gate, so it answers with the
+ // scenario's count while every other call gets the contextual list.
+ '/api/projects/:id/subscriptions/': (info) =>
+ new URL(info.request.url).searchParams.get('limit') === '1'
+ ? { count: freeTierSubscriptionCount ?? 0, results: [] }
+ : listSubscriptions(info),
'/api/projects/:id/subscriptions/summary_quota': aiSummaryAtLimit
? { active_count: 10, limit: 10, at_limit: true }
: { active_count: 0, limit: 10, at_limit: false },