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 ai observability (#104357)

Julian Bezcc6b51920c88
diff --git a/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml b/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml
index ea270c3f0e77..a62a827dad92 100644
--- a/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml
+++ b/.semgrep/rules/devex/no-environments-api-urls-frontend.yaml
@@ -50,24 +50,9 @@ 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.
- - '/products/ai_observability/frontend/aiObservabilitySessionDataLogic.ts'
- - '/products/ai_observability/frontend/clusters/clusteringConfigLogic.ts'
- - '/products/ai_observability/frontend/clusters/clusteringJobsLogic.ts'
- - '/products/ai_observability/frontend/clusters/clustersAdminLogic.ts'
- - '/products/ai_observability/frontend/evaluations/evaluationReportLogic.ts'
- - '/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts'
- - '/products/ai_observability/frontend/evaluations/llmEvaluationsLogic.ts'
- - '/products/ai_observability/frontend/llmGenerationSentimentLazyLoaderLogic.ts'
- - '/products/ai_observability/frontend/llmPersonsLazyLoaderLogic.ts'
- - '/products/ai_observability/frontend/llmSentimentLazyLoaderLogic.ts'
- '/products/ai_observability/frontend/playground/llmPlaygroundModelLogic.ts'
- '/products/ai_observability/frontend/playground/llmPlaygroundPromptsLogic.ts'
- '/products/ai_observability/frontend/settings/llmProviderKeysLogic.ts'
- - '/products/ai_observability/frontend/summary-view/summaryViewLogic.ts'
- - '/products/ai_observability/frontend/tags/llmTaggerLogic.ts'
- - '/products/ai_observability/frontend/tags/llmTaggersLogic.ts'
- - '/products/ai_observability/frontend/text-view/textViewLogic.ts'
- - '/products/ai_observability/frontend/traceReviews/traceReviewsApi.ts'
# No leading slash on the regex — catches both `/api/environments/` and
# bare `api/environments/` (the form used by api.get/create callers).
pattern-regex: 'api/environments/'
diff --git a/products/ai_observability/frontend/clusters/clusteringConfigLogic.ts b/products/ai_observability/frontend/clusters/clusteringConfigLogic.ts
index 50f2b17da4d5..7a544a5d01cd 100644
--- a/products/ai_observability/frontend/clusters/clusteringConfigLogic.ts
+++ b/products/ai_observability/frontend/clusters/clusteringConfigLogic.ts
@@ -89,14 +89,14 @@ export const clusteringConfigLogic = kea<clusteringConfigLogicType>([
loadConfig: async () => {
// nosemgrep: prefer-codegen-api
const response = await api.get(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_config/`
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_config/`
)
return response as ClusteringConfig
},
saveEventFilters: async () => {
// nosemgrep: prefer-codegen-api
const response = await api.create(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_config/set_event_filters/`,
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_config/set_event_filters/`,
{
event_filters: values.localEventFilters,
}
diff --git a/products/ai_observability/frontend/clusters/clusteringJobsLogic.ts b/products/ai_observability/frontend/clusters/clusteringJobsLogic.ts
index ec25f4bad330..3d9d3650482d 100644
--- a/products/ai_observability/frontend/clusters/clusteringJobsLogic.ts
+++ b/products/ai_observability/frontend/clusters/clusteringJobsLogic.ts
@@ -108,21 +108,21 @@ export const clusteringJobsLogic = kea<clusteringJobsLogicType>([
loadJobs: async () => {
// nosemgrep: prefer-codegen-api
const response = await api.get(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`
)
return (response.results ?? response) as ClusteringJob[]
},
createJob: async (payload: Partial<ClusteringJob>) => {
// nosemgrep: prefer-codegen-api
await api.create(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`,
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`,
payload
)
lemonToast.success('Clustering job created')
// Reload to get server-assigned fields
// nosemgrep: prefer-codegen-api
const response = await api.get(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`
)
return (response.results ?? response) as ClusteringJob[]
},
@@ -130,13 +130,13 @@ export const clusteringJobsLogic = kea<clusteringJobsLogicType>([
const { id, ...data } = payload
// nosemgrep: prefer-codegen-api
await api.update(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/${id}/`,
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/${id}/`,
data
)
lemonToast.success('Clustering job updated')
// nosemgrep: prefer-codegen-api
const response = await api.get(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/`
)
return (response.results ?? response) as ClusteringJob[]
},
@@ -168,9 +168,7 @@ export const clusteringJobsLogic = kea<clusteringJobsLogicType>([
deleteJob: async ({ jobId }) => {
try {
// nosemgrep: prefer-codegen-api
- await api.delete(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/${jobId}/`
- )
+ await api.delete(`api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_jobs/${jobId}/`)
lemonToast.success('Clustering job deleted')
posthog.capture('llma clustering job deleted', { job_id: jobId })
actions.loadJobs()
diff --git a/products/ai_observability/frontend/clusters/clustersAdminLogic.ts b/products/ai_observability/frontend/clusters/clustersAdminLogic.ts
index 91f7ba2ab356..29de08f742e4 100644
--- a/products/ai_observability/frontend/clusters/clustersAdminLogic.ts
+++ b/products/ai_observability/frontend/clusters/clustersAdminLogic.ts
@@ -151,7 +151,7 @@ export const clustersAdminLogic = kea<clustersAdminLogicType>([
triggerClusteringRun: async () => {
// nosemgrep: prefer-codegen-api
const response = await api.create(
- `api/environments/${values.currentTeamIdStrict}/llm_analytics/clustering_runs`,
+ `api/projects/${values.currentTeamIdStrict}/llm_analytics/clustering_runs`,
values.params
)
return response as ClusteringRunResponse
diff --git a/products/ai_observability/frontend/llmPersonsLazyLoaderLogic.ts b/products/ai_observability/frontend/llmPersonsLazyLoaderLogic.ts
index 081ce94b9554..c1380def8f53 100644
--- a/products/ai_observability/frontend/llmPersonsLazyLoaderLogic.ts
+++ b/products/ai_observability/frontend/llmPersonsLazyLoaderLogic.ts
@@ -180,7 +180,7 @@ export const llmPersonsLazyLoaderLogic = kea<llmPersonsLazyLoaderLogicType>([
try {
// nosemgrep: prefer-codegen-api
const response = await api.create<BatchByDistinctIdsResponse>(
- `api/environments/${teamId}/persons/batch_by_distinct_ids/`,
+ `api/projects/${teamId}/persons/batch_by_distinct_ids/`,
{ distinct_ids: batch }
)
diff --git a/products/ai_observability/frontend/tags/llmTaggerLogic.ts b/products/ai_observability/frontend/tags/llmTaggerLogic.ts
index 33ae7f672b69..aab73eaf3056 100644
--- a/products/ai_observability/frontend/tags/llmTaggerLogic.ts
+++ b/products/ai_observability/frontend/tags/llmTaggerLogic.ts
@@ -431,11 +431,11 @@ export const llmTaggerLogic = kea<llmTaggerLogicType>([
if (props.id === 'new') {
// nosemgrep: prefer-codegen-api
- await api.create('api/environments/@current/taggers/', payload)
+ await api.create(`api/projects/${teamLogic.values.currentTeamId}/taggers/`, payload)
lemonToast.success('Tagger created')
} else {
// nosemgrep: prefer-codegen-api
- await api.update(`api/environments/@current/taggers/${props.id}/`, payload)
+ await api.update(`api/projects/${teamLogic.values.currentTeamId}/taggers/${props.id}/`, payload)
lemonToast.success('Tagger updated')
}
// Reload list before navigating so the new/updated tagger is visible
@@ -455,7 +455,7 @@ export const llmTaggerLogic = kea<llmTaggerLogicType>([
try {
const teamId = teamLogic.values.currentTeamId
// nosemgrep: prefer-codegen-api
- const response = await api.create(`/api/environments/${teamId}/taggers/test_hog/`, {
+ const response = await api.create(`/api/projects/${teamId}/taggers/test_hog/`, {
source,
sample_count: 5,
tags: config.tags.filter((t: { name: string }) => t.name.trim()),
@@ -529,7 +529,7 @@ export const llmTaggerLogic = kea<llmTaggerLogicType>([
// the UI is stuck on the skeleton indefinitely on any API error.
try {
// nosemgrep: prefer-codegen-api
- const tagger = await api.get(`api/environments/@current/taggers/${props.id}/`)
+ const tagger = await api.get(`api/projects/${teamLogic.values.currentTeamId}/taggers/${props.id}/`)
actions.loadTaggerSuccess(tagger)
actions.setTaggerFormValues({
name: tagger.name,
@@ -550,7 +550,7 @@ export const llmTaggerLogic = kea<llmTaggerLogicType>([
return
}
// nosemgrep: prefer-codegen-api
- await api.update(`api/environments/@current/taggers/${props.id}/`, { deleted: true })
+ await api.update(`api/projects/${teamLogic.values.currentTeamId}/taggers/${props.id}/`, { deleted: true })
lemonToast.success('Tagger deleted')
router.actions.push(urls.aiObservabilityTags())
},
diff --git a/products/ai_observability/frontend/tags/llmTaggersLogic.ts b/products/ai_observability/frontend/tags/llmTaggersLogic.ts
index 4796f4fe56e4..2a7c2962e12f 100644
--- a/products/ai_observability/frontend/tags/llmTaggersLogic.ts
+++ b/products/ai_observability/frontend/tags/llmTaggersLogic.ts
@@ -378,7 +378,7 @@ export const llmTaggersLogic = kea<llmTaggersLogicType>([
listeners(({ actions, values }) => ({
loadTaggers: async () => {
// nosemgrep: prefer-codegen-api
- const response = await api.get('api/environments/@current/taggers/')
+ const response = await api.get(`api/projects/${teamLogic.values.currentTeamId}/taggers/`)
actions.loadTaggersSuccess(response.results)
},
loadTaggersSuccess: () => {
@@ -391,7 +391,9 @@ export const llmTaggersLogic = kea<llmTaggersLogicType>([
return
}
// nosemgrep: prefer-codegen-api
- await api.update(`api/environments/@current/taggers/${id}/`, { enabled: !tagger.enabled })
+ await api.update(`api/projects/${teamLogic.values.currentTeamId}/taggers/${id}/`, {
+ enabled: !tagger.enabled,
+ })
await breakpoint(100)
actions.loadTaggers()
},
diff --git a/products/ai_observability/frontend/text-view/textViewLogic.ts b/products/ai_observability/frontend/text-view/textViewLogic.ts
index 28c86c869685..d0708f8d6be6 100644
--- a/products/ai_observability/frontend/text-view/textViewLogic.ts
+++ b/products/ai_observability/frontend/text-view/textViewLogic.ts
@@ -194,7 +194,7 @@ export const textViewLogic = kea<textViewLogicType>([
// Call Django API with timeout
// nosemgrep: prefer-codegen-api
const response = await api.create(
- `api/environments/${props.teamId}/llm_analytics/text_repr/`,
+ `api/projects/${props.teamId}/llm_analytics/text_repr/`,
requestData,
{ signal: abortController.signal }
)
diff --git a/products/ai_observability/frontend/traceReviews/traceReviewsApi.ts b/products/ai_observability/frontend/traceReviews/traceReviewsApi.ts
index c14bab1af4b0..c37ee1997290 100644
--- a/products/ai_observability/frontend/traceReviews/traceReviewsApi.ts
+++ b/products/ai_observability/frontend/traceReviews/traceReviewsApi.ts
@@ -32,7 +32,7 @@ function isDuplicateTraceReviewError(error: unknown): boolean {
}
function getTraceReviewsBaseUrl(teamId: number = ApiConfig.getCurrentTeamId()): string {
- return `/api/environments/${teamId}/llm_analytics/trace_reviews/`
+ return `/api/projects/${teamId}/llm_analytics/trace_reviews/`
}
export interface TraceReviewListFilters {