: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(workflows): save to the tab's project, not the account's current one (#92741)
jake sciottoe7f43bcc500f
diff --git a/frontend/src/lib/api.test.ts b/frontend/src/lib/api.test.tsindex 128e94c3d3eb..749c0820f66e 100644--- a/frontend/src/lib/api.test.ts+++ b/frontend/src/lib/api.test.ts@@ -164,6 +164,38 @@ describe('API helper', () => {})})+ describe('workflow endpoints', () => {+ // These must carry the team id of the tab that issues them. `@current` resolves server-side to+ // the account's last-switched project, so a second tab on another project makes every save 404.+ it.each([+ [+ 'hogFlows.updateHogFlow',+ () => api.hogFlows.updateHogFlow('flow-1', {}),+ '/api/environments/2/hog_flows/flow-1/',+ ],+ ['hogFlows.createHogFlow', () => api.hogFlows.createHogFlow({}), '/api/environments/2/hog_flows/'],+ [+ 'messaging.updateTemplate',+ () => api.messaging.updateTemplate('template-1', {}),+ '/api/environments/2/messaging_templates/template-1/',+ ],+ [+ 'messaging.getCategory',+ () => api.messaging.getCategory('category-1'),+ '/api/environments/2/messaging_categories/category-1/',+ ],+ [+ 'messaging.generateMessagingPreferencesLink',+ () => api.messaging.generateMessagingPreferencesLink(),+ '/api/environments/2/messaging_preferences/generate_link/',+ ],+ ])("%s targets the tab's team, not @current", async (_name, request, expected) => {+ await request()++ expect(fakeFetch.mock.calls[0][0]).toEqual(expected)+ })+ })+describe('getting URLs', () => {const testCases = [{diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.tsindex c34002267316..27e406e590fc 100644--- a/frontend/src/lib/api.ts+++ b/frontend/src/lib/api.ts@@ -1945,7 +1945,7 @@ export class ApiRequest {}public messagingTemplates(): ApiRequest {- return this.environments().current().addPathComponent('messaging_templates')+ return this.environmentsDetail().addPathComponent('messaging_templates')}public messagingTemplate(templateId: MessageTemplate['id']): ApiRequest {@@ -1953,7 +1953,7 @@ export class ApiRequest {}public messagingCategories(): ApiRequest {- return this.environments().current().addPathComponent('messaging_categories')+ return this.environmentsDetail().addPathComponent('messaging_categories')}public messagingCategory(categoryId: string): ApiRequest {@@ -1989,29 +1989,23 @@ export class ApiRequest {}public messagingPreferences(): ApiRequest {- return this.environments().current().addPathComponent('messaging_preferences')+ return this.environmentsDetail().addPathComponent('messaging_preferences')}public messagingPreferencesLink(): ApiRequest {- return this.environments().current().addPathComponent('messaging_preferences').addPathComponent('generate_link')+ return this.messagingPreferences().addPathComponent('generate_link')}public messagingPreferencesExportOptOutsCsv(): ApiRequest {- return this.environments()- .current()- .addPathComponent('messaging_preferences')- .addPathComponent('export_opt_outs_csv')+ return this.messagingPreferences().addPathComponent('export_opt_outs_csv')}public messagingPreferencesBulkAddOptOuts(): ApiRequest {- return this.environments()- .current()- .addPathComponent('messaging_preferences')- .addPathComponent('bulk_add_opt_outs')+ return this.messagingPreferences().addPathComponent('bulk_add_opt_outs')}public hogFlows(): ApiRequest {- return this.environments().current().addPathComponent('hog_flows')+ return this.environmentsDetail().addPathComponent('hog_flows')}public hogFlow(hogFlowId: HogFlow['id']): ApiRequest {@@ -2019,7 +2013,7 @@ export class ApiRequest {}public hogFlowTemplates(): ApiRequest {- return this.environments().current().addPathComponent('hog_flow_templates')+ return this.environmentsDetail().addPathComponent('hog_flow_templates')}public hogFlowTemplate(hogFlowTemplateId: HogFlowTemplate['id']): ApiRequest {