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.

chore(devex): use the projects api path in platform scenes (#104354)

Julian Bez315b03d444aa
diff --git a/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml b/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml
index a4a61c956839..3e73fe71f628 100644
--- a/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml
+++ b/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml
@@ -50,25 +50,8 @@ rules:
# Each file below still constructs hand-coded `/api/environments/`
# or `api/environments/` URLs. Removing a file from this list
# re-enables the gate for it.
- - '/frontend/src/scenes/approvals/approvalLogic.tsx'
- - '/frontend/src/scenes/approvals/approvalsLogic.tsx'
- - '/frontend/src/scenes/approvals/changeRequestsLogic.ts'
- - '/frontend/src/scenes/approvals/pendingApprovalsLogic.ts'
- - '/frontend/src/scenes/audit-logs/ExportsListHelpers.tsx'
- - '/frontend/src/scenes/audit-logs/advancedActivityLogsLogic.tsx'
- - '/frontend/src/scenes/authentication/cli/cliLiveLogic.ts'
- '/products/groups/frontend/logics/groupLogic.ts'
- '/products/groups/frontend/logics/relatedGroupsLogic.ts'
- - '/frontend/src/scenes/health/categoryDetail/healthCategoryDetailLogic.ts'
- - '/frontend/src/scenes/health/healthSceneLogic.tsx'
- - '/frontend/src/scenes/health/pipelineStatus/pipelineHealthLogic.ts'
- - '/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx'
- - '/frontend/src/scenes/settings/environment/coreEventsLogic.ts'
- - '/frontend/src/scenes/settings/environment/experimentsConfigLogic.ts'
- - '/frontend/src/scenes/settings/organization/Approvals/approvalPoliciesLogic.tsx'
- - '/frontend/src/scenes/teamLogic.tsx'
- - '/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsSettingsLogic.ts'
- - '/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utmAuditLogic.ts'
- '/products/ai_observability/frontend/aiObservabilitySessionDataLogic.ts'
- '/products/ai_observability/frontend/clusters/clusteringConfigLogic.ts'
- '/products/ai_observability/frontend/clusters/clusteringJobsLogic.ts'
diff --git a/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.test.ts b/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.test.ts
index 0e70a7f3eeb7..2ca3ad1bb3b2 100644
--- a/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.test.ts
+++ b/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.test.ts
@@ -68,7 +68,7 @@ describe('the authorized urls list logic', () => {
describe('applying a suggestion', () => {
// Regression coverage: the `addUrl` listener must await `saveUrls` before triggering
- // `markTaskAsCompleted`. Both send PATCHes to /api/environments/:id, and the `currentTeam`
+ // `markTaskAsCompleted`. Both send PATCHes to /api/projects/:id, and the `currentTeam`
// subscription in this logic replaces local `authorizedUrls` from whichever response lands
// last. If the onboarding-tasks PATCH fires in parallel with the app_urls PATCH, its
// response can carry a stale app_urls snapshot and wipe the just-added URL out of the UI.
@@ -93,7 +93,7 @@ describe('the authorized urls list logic', () => {
await flushPromises()
expect(api.update).toHaveBeenCalledWith(
- `api/environments/${MOCK_TEAM_ID}`,
+ `api/projects/${MOCK_TEAM_ID}`,
expect.objectContaining({
app_urls: expect.arrayContaining(['https://new-suggestion.example.com']),
})
@@ -149,7 +149,7 @@ describe('the authorized urls list logic', () => {
logic.actions.submitProposedUrl()
}).toFinishAllListeners()
- expect(update).toHaveBeenCalledWith(`api/environments/${MOCK_TEAM_ID}`, {
+ expect(update).toHaveBeenCalledWith(`api/projects/${MOCK_TEAM_ID}`, {
app_urls: ['https://www.example.com'],
})
})
@@ -303,7 +303,7 @@ describe('the authorized urls list logic', () => {
expectLogic(logic, () => logic.actions.addUrl('http://*.example.com')).toFinishAllListeners()
- expect(api.update).toHaveBeenCalledWith(`api/environments/${MOCK_TEAM_ID}`, {
+ expect(api.update).toHaveBeenCalledWith(`api/projects/${MOCK_TEAM_ID}`, {
recording_domains: ['https://recordings.posthog.com/', 'http://*.example.com'],
})
})
diff --git a/frontend/src/scenes/approvals/approvalLogic.tsx b/frontend/src/scenes/approvals/approvalLogic.tsx
index 18279b677234..80e49afb296f 100644
--- a/frontend/src/scenes/approvals/approvalLogic.tsx
+++ b/frontend/src/scenes/approvals/approvalLogic.tsx
@@ -117,7 +117,7 @@ export const approvalLogic = kea<approvalLogicType>([
}
const response = await api.get<ChangeRequest>(
- `api/environments/${values.currentTeamId}/change_requests/${props.id}/`
+ `api/projects/${values.currentTeamId}/change_requests/${props.id}/`
)
return response
},
@@ -176,7 +176,7 @@ export const approvalLogic = kea<approvalLogicType>([
approveChangeRequest: async ({ reason }) => {
try {
const response = await api.create(
- `api/environments/${values.currentTeamId}/change_requests/${props.id}/approve/`,
+ `api/projects/${values.currentTeamId}/change_requests/${props.id}/approve/`,
{ reason: reason || '' }
)
@@ -196,7 +196,7 @@ export const approvalLogic = kea<approvalLogicType>([
},
rejectChangeRequest: async ({ reason }) => {
try {
- await api.create(`api/environments/${values.currentTeamId}/change_requests/${props.id}/reject/`, {
+ await api.create(`api/projects/${values.currentTeamId}/change_requests/${props.id}/reject/`, {
reason,
})
lemonToast.success('Change request rejected')
@@ -207,7 +207,7 @@ export const approvalLogic = kea<approvalLogicType>([
},
cancelChangeRequest: async ({ reason }) => {
try {
- await api.create(`api/environments/${values.currentTeamId}/change_requests/${props.id}/cancel/`, {
+ await api.create(`api/projects/${values.currentTeamId}/change_requests/${props.id}/cancel/`, {
reason,
})
lemonToast.success('Change request canceled')
diff --git a/frontend/src/scenes/approvals/approvalsLogic.tsx b/frontend/src/scenes/approvals/approvalsLogic.tsx
index 6fd0113b6555..3ea9d97ccf25 100644
--- a/frontend/src/scenes/approvals/approvalsLogic.tsx
+++ b/frontend/src/scenes/approvals/approvalsLogic.tsx
@@ -139,7 +139,7 @@ export const approvalsLogic = kea<approvalsLogicType>([
const actualUrl =
url ||
- `api/environments/${values.currentTeamId}/change_requests/?${new URLSearchParams({
+ `api/projects/${values.currentTeamId}/change_requests/?${new URLSearchParams({
...(values.filters.state && { state: values.filters.state }),
...(values.filters.action_key && { action_key: values.filters.action_key }),
...(values.filters.resource_type && { resource_type: values.filters.resource_type }),
@@ -184,7 +184,7 @@ export const approvalsLogic = kea<approvalsLogicType>([
actions.loadChangeRequests()
},
loadMore: async () => {
- const nextUrl = `api/environments/${values.currentTeamId}/change_requests/?${new URLSearchParams({
+ const nextUrl = `api/projects/${values.currentTeamId}/change_requests/?${new URLSearchParams({
offset: values.changeRequests.length.toString(),
...(values.filters.state && { state: values.filters.state }),
...(values.filters.action_key && { action_key: values.filters.action_key }),
@@ -197,7 +197,7 @@ export const approvalsLogic = kea<approvalsLogicType>([
},
approveChangeRequest: async ({ id, reason }) => {
try {
- await api.create(`api/environments/${values.currentTeamId}/change_requests/${id}/approve/`, {
+ await api.create(`api/projects/${values.currentTeamId}/change_requests/${id}/approve/`, {
reason: reason || '',
})
lemonToast.success('Change request approved')
@@ -208,7 +208,7 @@ export const approvalsLogic = kea<approvalsLogicType>([
},
rejectChangeRequest: async ({ id, reason }) => {
try {
- await api.create(`api/environments/${values.currentTeamId}/change_requests/${id}/reject/`, {
+ await api.create(`api/projects/${values.currentTeamId}/change_requests/${id}/reject/`, {
reason,
})
lemonToast.success('Change request rejected')
diff --git a/frontend/src/scenes/approvals/changeRequestsLogic.ts b/frontend/src/scenes/approvals/changeRequestsLogic.ts
index 39a8f8054a18..746c14f50c33 100644
--- a/frontend/src/scenes/approvals/changeRequestsLogic.ts
+++ b/frontend/src/scenes/approvals/changeRequestsLogic.ts
@@ -166,7 +166,7 @@ export const changeRequestsLogic = kea<changeRequestsLogicType>([
}
const response = await api.get(
- `api/environments/${values.currentTeamId}/change_requests?${toParams(params)}`
+ `api/projects/${values.currentTeamId}/change_requests?${toParams(params)}`
)
return response.results || []
},
@@ -207,7 +207,7 @@ export const changeRequestsLogic = kea<changeRequestsLogicType>([
approveRequest: async ({ id }) => {
try {
const response = await api.create(
- `api/environments/${values.currentTeamId}/change_requests/${id}/approve/`,
+ `api/projects/${values.currentTeamId}/change_requests/${id}/approve/`,
{}
)
@@ -231,7 +231,7 @@ export const changeRequestsLogic = kea<changeRequestsLogicType>([
rejectRequest: async ({ id, reason }) => {
try {
- await api.create(`api/environments/${values.currentTeamId}/change_requests/${id}/reject/`, { reason })
+ await api.create(`api/projects/${values.currentTeamId}/change_requests/${id}/reject/`, { reason })
lemonToast.success('Change request rejected')
actions.loadChangeRequestsSuccess(values.changeRequests.filter((cr) => cr.id !== id))
} catch (error: any) {
@@ -241,7 +241,7 @@ export const changeRequestsLogic = kea<changeRequestsLogicType>([
cancelRequest: async ({ id, reason }) => {
try {
- await api.create(`api/environments/${values.currentTeamId}/change_requests/${id}/cancel/`, { reason })
+ await api.create(`api/projects/${values.currentTeamId}/change_requests/${id}/cancel/`, { reason })
lemonToast.success('Change request canceled')
// Optimistically remove the canceled CR so the banner disappears immediately
actions.loadChangeRequestsSuccess(values.changeRequests.filter((cr) => cr.id !== id))
diff --git a/frontend/src/scenes/approvals/pendingApprovalsLogic.ts b/frontend/src/scenes/approvals/pendingApprovalsLogic.ts
index e2e9a3607961..7dc59d34057b 100644
--- a/frontend/src/scenes/approvals/pendingApprovalsLogic.ts
+++ b/frontend/src/scenes/approvals/pendingApprovalsLogic.ts
@@ -72,7 +72,7 @@ export const pendingApprovalsLogic = kea<pendingApprovalsLogicType>([
}
const response = await api.get(
- `api/environments/${values.currentTeamId}/change_requests?${toParams({ state: 'pending,approved' })}`
+ `api/projects/${values.currentTeamId}/change_requests?${toParams({ state: 'pending,approved' })}`
)
return response.results || []
},
diff --git a/frontend/src/scenes/audit-logs/ExportsListHelpers.tsx b/frontend/src/scenes/audit-logs/ExportsListHelpers.tsx
index 9decabf9fd4b..50c5d9159232 100644
--- a/frontend/src/scenes/audit-logs/ExportsListHelpers.tsx
+++ b/frontend/src/scenes/audit-logs/ExportsListHelpers.tsx
@@ -219,7 +219,7 @@ export const getFilterTooltip = (exportAsset: ExportedAsset): JSX.Element => {
export const downloadExport = (exportAsset: ExportedAsset): void => {
const link = document.createElement('a')
- link.href = `/api/environments/${teamLogic.values.currentTeamIdStrict}/exports/${exportAsset.id}/content/?download=true`
+ link.href = `/api/projects/${teamLogic.values.currentTeamIdStrict}/exports/${exportAsset.id}/content/?download=true`
link.download = exportAsset.filename || ''
document.body.appendChild(link)
link.click()
diff --git a/frontend/src/scenes/audit-logs/advancedActivityLogsLogic.tsx b/frontend/src/scenes/audit-logs/advancedActivityLogsLogic.tsx
index 84223041e478..b4f5e7cf8ed2 100644
--- a/frontend/src/scenes/audit-logs/advancedActivityLogsLogic.tsx
+++ b/frontend/src/scenes/audit-logs/advancedActivityLogsLogic.tsx
@@ -489,7 +489,7 @@ export const advancedActivityLogsLogic = kea<advancedActivityLogsLogicType>([
loadExports: async () => {
const params = new URLSearchParams()
params.append('context_path', '/advanced_activity_logs/')
- const response = await api.get(`api/environments/${values.currentTeamIdStrict}/exports/?${params}`)
+ const response = await api.get(`api/projects/${values.currentTeamIdStrict}/exports/?${params}`)
return response.results || []
},
},
diff --git a/frontend/src/scenes/authentication/cli/cliLiveLogic.ts b/frontend/src/scenes/authentication/cli/cliLiveLogic.ts
index a34e8d5711a3..2265c4b9fdf2 100644
--- a/frontend/src/scenes/authentication/cli/cliLiveLogic.ts
+++ b/frontend/src/scenes/authentication/cli/cliLiveLogic.ts
@@ -119,7 +119,7 @@ export const cliLiveLogic = kea<cliLiveLogicType>([
}
try {
- const team = await api.get(`api/environments/${projectId}/`)
+ const team = await api.get(`api/projects/${projectId}/`)
const token = team.live_events_token
if (!token) {
actions.setError('Live events token not available for this project')
diff --git a/frontend/src/scenes/health/categoryDetail/healthCategoryDetailLogic.ts b/frontend/src/scenes/health/categoryDetail/healthCategoryDetailLogic.ts
index c8d15e87c716..1ae0b7b371fc 100644
--- a/frontend/src/scenes/health/categoryDetail/healthCategoryDetailLogic.ts
+++ b/frontend/src/scenes/health/categoryDetail/healthCategoryDetailLogic.ts
@@ -152,7 +152,7 @@ export const healthCategoryDetailLogic = kea<healthCategoryDetailLogicType>([
}
const queryString = new URLSearchParams(params).toString()
- const url = `api/environments/${values.currentTeamIdStrict}/health_issues/?${queryString}`
+ const url = `api/projects/${values.currentTeamIdStrict}/health_issues/?${queryString}`
try {
return await api.get(url)
} catch {
@@ -251,7 +251,7 @@ export const healthCategoryDetailLogic = kea<healthCategoryDetailLogicType>([
},
snoozeIssue: async ({ id, duration }) => {
try {
- await api.update(`api/environments/${values.currentTeamIdStrict}/health_issues/${id}/`, {
+ await api.update(`api/projects/${values.currentTeamIdStrict}/health_issues/${id}/`, {
snoozed_until: duration,
})
actions.loadHealthIssues()
@@ -262,7 +262,7 @@ export const healthCategoryDetailLogic = kea<healthCategoryDetailLogicType>([
},
dismissIssue: async ({ id }) => {
try {
- await api.update(`api/environments/${values.currentTeamIdStrict}/health_issues/${id}/`, {
+ await api.update(`api/projects/${values.currentTeamIdStrict}/health_issues/${id}/`, {
dismissed: true,
})
actions.loadHealthIssues()
@@ -273,7 +273,7 @@ export const healthCategoryDetailLogic = kea<healthCategoryDetailLogicType>([
},
undismissIssue: async ({ id }) => {
try {
- await api.update(`api/environments/${values.currentTeamIdStrict}/health_issues/${id}/`, {
+ await api.update(`api/projects/${values.currentTeamIdStrict}/health_issues/${id}/`, {
dismissed: false,
})
actions.loadHealthIssues()
diff --git a/frontend/src/scenes/health/healthSceneLogic.tsx b/frontend/src/scenes/health/healthSceneLogic.tsx
index 666964fa3ee8..399558f3ff57 100644
--- a/frontend/src/scenes/health/healthSceneLogic.tsx
+++ b/frontend/src/scenes/health/healthSceneLogic.tsx
@@ -154,7 +154,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([
}
const queryString = new URLSearchParams(params).toString()
- const url = `api/environments/${values.currentTeamIdStrict}/health_issues/?${queryString}`
+ const url = `api/projects/${values.currentTeamIdStrict}/health_issues/?${queryString}`
return await api.get(url)
},
@@ -217,7 +217,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([
}),
listeners(({ actions, values }) => ({
refreshHealthData: async ({ isManual }, breakpoint) => {
- const url = `api/environments/${values.currentTeamIdStrict}/health_issues/refresh/`
+ const url = `api/projects/${values.currentTeamIdStrict}/health_issues/refresh/`
try {
const response = await api.create<{
scheduled_kinds: string[]
@@ -285,7 +285,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([
},
snoozeIssue: async ({ id, duration }) => {
try {
- await api.update(`api/environments/${values.currentTeamIdStrict}/health_issues/${id}/`, {
+ await api.update(`api/projects/${values.currentTeamIdStrict}/health_issues/${id}/`, {
snoozed_until: duration,
})
actions.loadHealthIssues()
@@ -296,7 +296,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([
},
dismissIssue: async ({ id }) => {
try {
- await api.update(`api/environments/${values.currentTeamIdStrict}/health_issues/${id}/`, {
+ await api.update(`api/projects/${values.currentTeamIdStrict}/health_issues/${id}/`, {
dismissed: true,
})
actions.loadHealthIssues()
@@ -307,7 +307,7 @@ export const healthSceneLogic = kea<healthSceneLogicType>([
},
undismissIssue: async ({ id }) => {
try {
- await api.update(`api/environments/${values.currentTeamIdStrict}/health_issues/${id}/`, {
+ await api.update(`api/projects/${values.currentTeamIdStrict}/health_issues/${id}/`, {
dismissed: false,
})
actions.loadHealthIssues()
diff --git a/frontend/src/scenes/health/pipelineStatus/pipelineHealthLogic.ts b/frontend/src/scenes/health/pipelineStatus/pipelineHealthLogic.ts
index f5d3201cbb0c..dfa07b47a444 100644
--- a/frontend/src/scenes/health/pipelineStatus/pipelineHealthLogic.ts
+++ b/frontend/src/scenes/health/pipelineStatus/pipelineHealthLogic.ts
@@ -111,7 +111,7 @@ export const pipelineHealthLogic = kea<pipelineHealthLogicType>([
}
try {
const response = await api.get<DataHealthIssuesResponse>(
- `api/environments/${values.currentTeamIdStrict}/data_warehouse/data_health_issues/`
+ `api/projects/${values.currentTeamIdStrict}/data_warehouse/data_health_issues/`
)
return response
} catch (error) {
diff --git a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
index 1b6a4e764253..1d03701baa7c 100644
--- a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
+++ b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
@@ -73,7 +73,7 @@ export const projectHomepageLogic = kea<projectHomepageLogicType>([
{
loadRecentInsights: async () => {
const insights = await api.get<InsightModel[]>(
- `api/environments/${values.currentProjectId}/insights/my_last_viewed`
+ `api/projects/${values.currentProjectId}/insights/my_last_viewed`
)
return insights.map((legacyInsight) => getQueryBasedInsightModel(legacyInsight))
},
diff --git a/frontend/src/scenes/settings/environment/coreEventsLogic.ts b/frontend/src/scenes/settings/environment/coreEventsLogic.ts
index 91cf5f0cfbe4..b9ac5ffc41b3 100644
--- a/frontend/src/scenes/settings/environment/coreEventsLogic.ts
+++ b/frontend/src/scenes/settings/environment/coreEventsLogic.ts
@@ -109,7 +109,7 @@ export const coreEventsLogic = kea<coreEventsLogicType>([
return []
}
try {
- const response = await api.get(`api/environments/${values.currentTeamId}/core_events/`)
+ const response = await api.get(`api/projects/${values.currentTeamId}/core_events/`)
const events = (response.results || []).map(toCoreEvent)
actions.setCoreEvents(events)
return events
@@ -128,7 +128,7 @@ export const coreEventsLogic = kea<coreEventsLogicType>([
return
}
try {
- await api.create(`api/environments/${values.currentTeamId}/core_events/`, event)
+ await api.create(`api/projects/${values.currentTeamId}/core_events/`, event)
actions.loadCoreEvents()
lemonToast.success('Core event added')
} catch {
@@ -140,7 +140,7 @@ export const coreEventsLogic = kea<coreEventsLogicType>([
return
}
try {
- await api.update(`api/environments/${values.currentTeamId}/core_events/${event.id}/`, event)
+ await api.update(`api/projects/${values.currentTeamId}/core_events/${event.id}/`, event)
actions.loadCoreEvents()
lemonToast.success('Core event updated')
} catch {
@@ -152,7 +152,7 @@ export const coreEventsLogic = kea<coreEventsLogicType>([
return
}
try {
- await api.delete(`api/environments/${values.currentTeamId}/core_events/${eventId}/`)
+ await api.delete(`api/projects/${values.currentTeamId}/core_events/${eventId}/`)
actions.loadCoreEvents()
lemonToast.success('Core event removed')
} catch {
diff --git a/frontend/src/scenes/settings/environment/experimentsConfigLogic.ts b/frontend/src/scenes/settings/environment/experimentsConfigLogic.ts
index 48b3902a4ae5..56e90277d7d8 100644
--- a/frontend/src/scenes/settings/environment/experimentsConfigLogic.ts
+++ b/frontend/src/scenes/settings/environment/experimentsConfigLogic.ts
@@ -77,7 +77,7 @@ export const experimentsConfigLogic = kea<experimentsConfigLogicType>([
null as ExperimentsConfig | null,
{
loadExperimentsConfig: async (): Promise<ExperimentsConfig> => {
- return await api.get(`api/environments/${values.currentTeamId}/experiments_config/`)
+ return await api.get(`api/projects/${values.currentTeamId}/experiments_config/`)
},
},
],
@@ -104,7 +104,7 @@ export const experimentsConfigLogic = kea<experimentsConfigLogicType>([
listeners(({ actions, values }) => ({
updateExperimentsConfig: async ({ payload }) => {
try {
- await api.update(`api/environments/${values.currentTeamId}/experiments_config/`, payload)
+ await api.update(`api/projects/${values.currentTeamId}/experiments_config/`, payload)
} catch (error: any) {
lemonToast.error(error.data?.detail || 'Failed to update experiment settings. Please try again.')
} finally {
diff --git a/frontend/src/scenes/settings/organization/Approvals/approvalPoliciesLogic.tsx b/frontend/src/scenes/settings/organization/Approvals/approvalPoliciesLogic.tsx
index 0d16ce4fb173..66300e1e2fe5 100644
--- a/frontend/src/scenes/settings/organization/Approvals/approvalPoliciesLogic.tsx
+++ b/frontend/src/scenes/settings/organization/Approvals/approvalPoliciesLogic.tsx
@@ -76,7 +76,7 @@ export const approvalPoliciesLogic = kea<approvalPoliciesLogicType>([
return []
}
const response = await api.get<{ results: ApprovalPolicy[] }>(
- `api/environments/${teamId}/approval_policies/`
+ `api/projects/${teamId}/approval_policies/`
)
return response.results || []
},
@@ -97,7 +97,7 @@ export const approvalPoliciesLogic = kea<approvalPoliciesLogicType>([
if (!teamId) {
throw new Error('No team selected')
}
- await api.create(`api/environments/${teamId}/approval_policies/`, policy)
+ await api.create(`api/projects/${teamId}/approval_policies/`, policy)
lemonToast.success('Approval policy created')
actions.loadPolicies()
} catch (error: any) {
@@ -110,7 +110,7 @@ export const approvalPoliciesLogic = kea<approvalPoliciesLogicType>([
if (!teamId) {
throw new Error('No team selected')
}
- await api.update(`api/environments/${teamId}/approval_policies/${id}/`, policy)
+ await api.update(`api/projects/${teamId}/approval_policies/${id}/`, policy)
lemonToast.success('Approval policy updated')
actions.loadPolicies()
} catch (error: any) {
@@ -123,7 +123,7 @@ export const approvalPoliciesLogic = kea<approvalPoliciesLogicType>([
if (!teamId) {
throw new Error('No team selected')
}
- await api.delete(`api/environments/${teamId}/approval_policies/${id}/`)
+ await api.delete(`api/projects/${teamId}/approval_policies/${id}/`)
lemonToast.success('Approval policy deleted')
actions.loadPolicies()
} catch (error: any) {
diff --git a/frontend/src/scenes/teamLogic.tsx b/frontend/src/scenes/teamLogic.tsx
index 32d76561e2d6..6658657a2f80 100644
--- a/frontend/src/scenes/teamLogic.tsx
+++ b/frontend/src/scenes/teamLogic.tsx
@@ -94,7 +94,7 @@ export async function completeProductOnboarding(
teamId: TeamType['id'] | string,
{ product_type, intent_context }: ProductOnboardingCompleteProperties
): Promise<TeamType | null> {
- return await api.update(`api/environments/${teamId}/complete_product_onboarding`, {
+ return await api.update(`api/projects/${teamId}/complete_product_onboarding`, {
product_type,
intent_context,
})
@@ -383,14 +383,14 @@ export const teamLogic = kea<teamLogicType>([
}
try {
- return await api.get('api/environments/@current')
+ return await api.get('api/projects/@current')
} catch {
return values.currentTeam
}
},
refreshCurrentTeam: async () => {
try {
- const team = await api.get('api/environments/@current')
+ const team = await api.get('api/projects/@current')
return team?.id === values.currentTeam?.id ? team : values.currentTeam
} catch {
return values.currentTeam
@@ -411,8 +411,8 @@ export const teamLogic = kea<teamLogicType>([
let patchedTeam: TeamType | TeamPublicType
if (Object.keys(payload).length === 1 && payload.name && values.currentTeam.project_id) {
- // Renames go through /api/projects, which mirrors the name onto the passthrough
- // team server-side. /api/environments is deprecated, don't add calls to it
+ // Renames go through the project id, because that mirrors the name onto the
+ // passthrough team server-side. Every other patch goes through the team id.
const patchedProject = await api.update<ProjectType>(
`api/projects/${values.currentTeam.project_id}`,
{ name: payload.name }
@@ -422,7 +422,7 @@ export const teamLogic = kea<teamLogicType>([
actions.loadCurrentProjectSuccess(patchedProject)
patchedTeam = { ...values.currentTeam, name: patchedProject.name }
} else {
- patchedTeam = await api.update(`api/environments/${values.currentTeam.id}`, payload)
+ patchedTeam = await api.update(`api/projects/${values.currentTeam.id}`, payload)
breakpoint()
}
@@ -499,12 +499,12 @@ export const teamLogic = kea<teamLogicType>([
return await api.create(`api/projects/${values.currentProject.id}/environments/`, { name, is_demo })
},
// Project API Token
- resetToken: async () => await api.update(`api/environments/${values.currentTeamId}/reset_token`, {}),
+ resetToken: async () => await api.update(`api/projects/${values.currentTeamId}/reset_token`, {}),
// Feature Flags Secure API Token
rotateSecretToken: async () =>
- await api.update(`api/environments/${values.currentTeamId}/rotate_secret_token`, {}),
+ await api.update(`api/projects/${values.currentTeamId}/rotate_secret_token`, {}),
deleteSecretTokenBackup: async () =>
- await api.update(`api/environments/${values.currentTeamId}/delete_secret_token_backup`, {}),
+ await api.update(`api/projects/${values.currentTeamId}/delete_secret_token_backup`, {}),
/**
* If adding a product intent that also represents regular product usage, see explainer in posthog.models.product_intent.product_intent.py.
* Also, we refresh the list of custom products to show the possible new entry in the sidebar after we've added the intent.
@@ -674,7 +674,7 @@ export const teamLogic = kea<teamLogicType>([
},
deleteTeam: async ({ team }) => {
try {
- await api.delete(`api/environments/${team.id}`)
+ await api.delete(`api/projects/${team.id}`)
location.reload()
actions.deleteTeamSuccess()
} catch {
diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsSettingsLogic.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsSettingsLogic.ts
index 7a1815f8d01b..a1615310e949 100644
--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsSettingsLogic.ts
+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsSettingsLogic.ts
@@ -639,7 +639,7 @@ export const marketingAnalyticsSettingsLogic = kea<marketingAnalyticsSettingsLog
testMapping: async ({ tableId, sourceMap }) => {
try {
const response = await api.create(
- `api/environments/${values.currentTeamId}/marketing_analytics/test_mapping/`,
+ `api/projects/${values.currentTeamId}/marketing_analytics/test_mapping/`,
{ table_id: tableId, source_map: sourceMap }
)
if (response.success) {
diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utmAuditLogic.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utmAuditLogic.ts
index fe5cc6564415..ed1e5a43c2bf 100644
--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utmAuditLogic.ts
+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utmAuditLogic.ts
@@ -258,7 +258,7 @@ export const utmAuditLogic = kea<utmAuditLogicType>([
date_from: '-30d',
}
const response = await api.get(
- `api/environments/${values.currentTeamId}/marketing_analytics/utm_audit`,
+ `api/projects/${values.currentTeamId}/marketing_analytics/utm_audit`,
params
)
return response as UtmAuditResponse
diff --git a/products/surveys/frontend/e2e/settings.spec.ts b/products/surveys/frontend/e2e/settings.spec.ts
index a20d88918174..aaac1663d315 100644
--- a/products/surveys/frontend/e2e/settings.spec.ts
+++ b/products/surveys/frontend/e2e/settings.spec.ts
@@ -33,7 +33,7 @@ test.describe('Survey Settings', () => {
async function toggleSurveysSettingsAndWaitResponse(page: Page): Promise<void> {
const responsePromise = page.waitForResponse(
- (resp) => resp.url().includes('/api/environments/') && resp.request().method() === 'PATCH'
+ (resp) => resp.url().includes('/api/projects/') && resp.request().method() === 'PATCH'
)
await page.locator('[data-attr="opt-in-surveys-switch"]').click()
await responsePromise