: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(error-tracking): remove cohort creation from issues (#119684)
Aleksander Błaszkiewicz1b9f3dda0682
diff --git a/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsx b/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsxindex f01907396d46..9dafc190f833 100644--- a/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsx+++ b/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsx@@ -4,14 +4,9 @@ import posthog from 'posthog-js'import api from 'lib/api'import { tryShowMCPHint } from 'lib/components/MCPHint/mcpHintLogic'import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'-import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'-import { BehavioralFilterKey } from 'scenes/cohorts/CohortFilters/types'-import { createCohortFormData } from 'scenes/cohorts/cohortUtils'import { teamLogic } from 'scenes/teamLogic'import { ErrorTrackingIssue } from '~/queries/schema/schema-general'-import { escapeHogQLString } from '~/queries/utils'-import { BehavioralEventType, CohortType, FilterLogicalOperator, PropertyFilterType } from '~/types'import type {ErrorTrackingIssueAssignee,@@ -47,15 +42,6 @@ export interface issueActionsLogicActions {clearNeedsReload: () => {value: true}- createIssueCohort: (- id: string,- name: string,- description: string- ) => {- description: string- id: string- name: string- }finishIssueSeverityUpdate: (id: string) => {id: string}@@ -168,7 +154,6 @@ export const issueActionsLogic = kea<issueActionsLogicType>([finishIssueSeverityUpdate: (id: string) => ({ id }),updateIssueName: (id: string, name: string) => ({ id, name }),updateIssueDescription: (id: string, description: string) => ({ id, description }),- createIssueCohort: (id: string, name: string, description: string) => ({ id, name, description }),splitIssueSuccess: (id: ErrorTrackingIssue['id'], newIssueIds: string[]) => ({ id, newIssueIds }),mutationSuccess: (mutationName: string, issueId?: string) => ({ mutationName, issueId }),@@ -316,23 +301,6 @@ export const issueActionsLogic = kea<issueActionsLogicType>([await api.errorTracking.updateIssue(id, { description })})},- createIssueCohort: async ({ id, name, description }) => {- await runMutation(- 'createIssueCohort',- async () => {- let cohortParams = createCohortParams(name, description, id)- let formData = createCohortFormData(cohortParams)- let cohort = await api.cohorts.create(formData as Partial<CohortType>)- posthog.capture('error_tracking_issue_create_cohort', {- issueId: id,- cohortId: cohort.id,- })- await api.errorTracking.assignCohort(id, cohort.id)- },- undefined,- id- )- },mutationSuccess: ({ mutationName }) => {if (mutationName === 'updateIssueAssignee' || mutationName === 'assignIssues') {tryShowMCPHint('error_tracking.assign')@@ -341,38 +309,3 @@ export const issueActionsLogic = kea<issueActionsLogicType>([}}),])--function createCohortParams(name: string, description: string, issueId: string): CohortType {- return {- id: 'new',- name,- description,- groups: [],- filters: {- properties: {- type: FilterLogicalOperator.Or,- values: [- {- type: FilterLogicalOperator.Or,- values: [- {- key: '$exception',- type: BehavioralFilterKey.Behavioral,- value: BehavioralEventType.PerformEvent,- negation: false,- event_type: TaxonomicFilterGroupType.Events,- event_filters: [- {- key: `issue_id = ${escapeHogQLString(issueId)}`,- type: PropertyFilterType.HogQL,- },- ],- explicit_datetime: '-30d',- },- ],- },- ],- },- },- }-}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/ErrorTrackingIssueScenePanel.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/ErrorTrackingIssueScenePanel.tsxindex 4f7e2204d700..c75728af5f40 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/ErrorTrackingIssueScenePanel.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/ErrorTrackingIssueScenePanel.tsx@@ -26,7 +26,6 @@ import { ExternalReferences } from '../../../components/ExternalReferences'import { manageFingerprintsLogic } from '../../../components/FingerprintPreview/manageFingerprintsLogic'import { errorTrackingIssueSceneLogic } from '../errorTrackingIssueSceneLogic'import { IssueAffectedBroadcastButton } from './IssueAffectedBroadcastButton'-import { IssueCohort } from './IssueCohort'import { IssueWorkflowButton } from './IssueWorkflowButton'export const ErrorTrackingIssueScenePanel = ({@@ -41,7 +40,6 @@ export const ErrorTrackingIssueScenePanel = ({<ScenePanelInfoSection><SceneActivityIndicator at={issue.first_seen} prefix="First seen" /><IssueExternalReference />- <IssueCohort issue={issue} /></ScenePanelInfoSection><ScenePanelDivider /><ScenePanelActionsSection>diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueCohort.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueCohort.tsxdeleted file mode 100644index cd7d25c7972b..000000000000--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueCohort.tsx+++ /dev/null@@ -1,78 +0,0 @@-import { useAsyncActions } from 'kea'-import { useCallback } from 'react'--import { LemonDialog, LemonInput, Link, lemonToast } from '@posthog/lemon-ui'--import { LemonField } from 'lib/lemon-ui/LemonField'-import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'-import { urls } from 'scenes/urls'--import { ScenePanelLabel } from '~/layout/scenes/SceneLayout'-import { ErrorTrackingIssueCohort, ErrorTrackingRelationalIssue } from '~/queries/schema/schema-general'--import { issueActionsLogic } from 'products/error_tracking/frontend/components/IssueActions/issueActionsLogic'--export function IssueCohort({ issue }: { issue: ErrorTrackingRelationalIssue }): JSX.Element {- const cohort = issue.cohort- return (- <ScenePanelLabel title="Cohort">- {cohort ? <IssueCohortDisplay issueId={issue.id} cohort={cohort} /> : <IssueCohortCreate issue={issue} />}- </ScenePanelLabel>- )-}--function IssueCohortCreate({ issue }: { issue: ErrorTrackingRelationalIssue }): JSX.Element {- const { createIssueCohort } = useAsyncActions(issueActionsLogic)-- const onCreate: IssueCohortFormHandler = useCallback(- async (name, description) => {- await createIssueCohort(issue.id, name, description ?? '')- lemonToast.success(`Cohort created`)- },- [issue, createIssueCohort]- )- return (- <ButtonPrimitive fullWidth onClick={() => createIssueCohortForm(issue, onCreate)}>- Create cohort- </ButtonPrimitive>- )-}--type IssueCohortFormHandler = (name: string, description?: string) => void--function createIssueCohortForm(issue: ErrorTrackingRelationalIssue, onSubmit: IssueCohortFormHandler): void {- LemonDialog.openForm({- title: 'Create cohort',- shouldAwaitSubmit: true,- initialValues: {- cohortName: `Impacted by Issue [${issue.name}${issue.description ? ` - ${issue.description.substring(0, 200)}` : ''}]`,- cohortDescription: new URL(urls.errorTrackingIssue(issue.id), window.location.href).toString(),- },- content: (- <div className="flex flex-col gap-y-2 w-[600px]">- <LemonField name="cohortName" label="Cohort Name">- <LemonInput data-attr="cohort-name" placeholder="Cohort name" size="small" />- </LemonField>- <LemonField name="cohortDescription" label="Cohort Description">- <LemonInput data-attr="cohort-description" placeholder="Cohort description" />- </LemonField>- </div>- ),- errors: {- cohortName: (name) => (!name ? 'You must enter a title' : undefined),- },- onSubmit: ({ cohortName, cohortDescription }) => {- return onSubmit(cohortName, cohortDescription)- },- })-}--function IssueCohortDisplay({ cohort }: { issueId: string; cohort: ErrorTrackingIssueCohort }): JSX.Element {- return (- <Link to={urls.cohort(cohort.id)} tooltip="Edit Cohort" target="_blank">- <ButtonPrimitive variant="panel" fullWidth>- {cohort.name}- </ButtonPrimitive>- </Link>- )-}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.tsindex 69263886955b..9c0944db4293 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts@@ -1099,11 +1099,6 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicType)}},- [issueActionsLogic.actionTypes.mutationSuccess]: ({ mutationName, issueId }) => {- if (mutationName === 'createIssueCohort' && issueId === props.id) {- actions.loadIssue()- }- },}}),