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.

feat(error-tracking): add issue severity field (#80514)

Hugues Pouillote459f0c5a538
diff --git a/products/error_tracking/backend/facade/api.py b/products/error_tracking/backend/facade/api.py
index 45538b9c961a..b853ab42e4a8 100644
--- a/products/error_tracking/backend/facade/api.py
+++ b/products/error_tracking/backend/facade/api.py
@@ -75,6 +75,7 @@ def _to_issue_preview(issue) -> contracts.ErrorTrackingIssuePreview:
return contracts.ErrorTrackingIssuePreview(
id=issue.id,
status=issue.status,
+ severity=issue.severity,
name=issue.name,
description=issue.description,
first_seen=getattr(issue, "first_seen", None),
@@ -86,6 +87,7 @@ def _to_issue(issue) -> contracts.ErrorTrackingIssue:
return contracts.ErrorTrackingIssue(
id=issue.id,
status=issue.status,
+ severity=issue.severity,
name=issue.name,
description=issue.description,
first_seen=getattr(issue, "first_seen", None),
diff --git a/products/error_tracking/backend/facade/contracts.py b/products/error_tracking/backend/facade/contracts.py
index cc5c7108f0f1..777805dc4335 100644
--- a/products/error_tracking/backend/facade/contracts.py
+++ b/products/error_tracking/backend/facade/contracts.py
@@ -15,6 +15,8 @@ from uuid import UUID
from pydantic.dataclasses import dataclass
+ERROR_TRACKING_ISSUE_SEVERITIES = ("low", "medium", "high", "critical")
+
@dataclass(frozen=True)
class ErrorTrackingIssueAssignee:
@@ -54,6 +56,7 @@ class ErrorTrackingFingerprint:
class ErrorTrackingIssuePreview:
id: UUID
status: str
+ severity: str | None
name: str | None
description: str | None
first_seen: datetime | None
@@ -64,6 +67,7 @@ class ErrorTrackingIssuePreview:
class ErrorTrackingIssue:
id: UUID
status: str
+ severity: str | None
name: str | None
description: str | None
first_seen: datetime | None
diff --git a/products/error_tracking/backend/logic/issue_mutations.py b/products/error_tracking/backend/logic/issue_mutations.py
index 8ee2fcf2b01f..1330b2c3db12 100644
--- a/products/error_tracking/backend/logic/issue_mutations.py
+++ b/products/error_tracking/backend/logic/issue_mutations.py
@@ -69,13 +69,16 @@ def update_issue(
# (first_seen, assignment, external issues, cohorts) without a second read.
issue = get_issue(issue_id=issue_id, team_id=team_id)
status_before = issue.status
+ severity_before = issue.severity
name_before = issue.name
status_after = fields.get("status")
+ severity_after = fields.get("severity")
name_after = fields.get("name")
status_updated = "status" in fields and status_after != status_before
+ severity_updated = "severity" in fields and severity_after != severity_before
name_updated = "name" in fields and name_after != name_before
- for key in ("status", "name", "description"):
+ for key in ("status", "severity", "name", "description"):
if key in fields:
setattr(issue, key, fields[key])
issue.save()
@@ -87,6 +90,16 @@ def update_issue(
type="ErrorTrackingIssue", field="status", before=status_before, after=status_after, action="changed"
)
)
+ if severity_updated:
+ changes.append(
+ Change(
+ type="ErrorTrackingIssue",
+ field="severity",
+ before=severity_before,
+ after=severity_after,
+ action="changed",
+ )
+ )
if name_updated:
changes.append(
Change(type="ErrorTrackingIssue", field="name", before=name_before, after=name_after, action="changed")
diff --git a/products/error_tracking/backend/migrations/0024_errortrackingissue_severity.py b/products/error_tracking/backend/migrations/0024_errortrackingissue_severity.py
new file mode 100644
index 000000000000..e4d4d6670982
--- /dev/null
+++ b/products/error_tracking/backend/migrations/0024_errortrackingissue_severity.py
@@ -0,0 +1,21 @@
+# Generated by Django 5.2.17 on 2026-08-10 12:08
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("error_tracking", "0023_symbolset_autovacuum_scale_factor"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="errortrackingissue",
+ name="severity",
+ field=models.TextField(
+ choices=[("low", "Low"), ("medium", "Medium"), ("high", "High"), ("critical", "Critical")],
+ default=None,
+ null=True,
+ ),
+ ),
+ ]
diff --git a/products/error_tracking/backend/migrations/max_migration.txt b/products/error_tracking/backend/migrations/max_migration.txt
index e6b5eb87ef52..e7819733869b 100644
--- a/products/error_tracking/backend/migrations/max_migration.txt
+++ b/products/error_tracking/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0023_symbolset_autovacuum_scale_factor
+0024_errortrackingissue_severity
diff --git a/products/error_tracking/backend/models.py b/products/error_tracking/backend/models.py
index 1bfbb00a1ef3..b8f87372106d 100644
--- a/products/error_tracking/backend/models.py
+++ b/products/error_tracking/backend/models.py
@@ -56,9 +56,16 @@ class ErrorTrackingIssue(UUIDTModel):
PENDING_RELEASE = "pending_release", "Pending release"
SUPPRESSED = "suppressed", "Suppressed"
+ class Severity(models.TextChoices):
+ LOW = "low", "Low"
+ MEDIUM = "medium", "Medium"
+ HIGH = "high", "High"
+ CRITICAL = "critical", "Critical"
+
team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
status = models.TextField(choices=Status, default=Status.ACTIVE, null=False)
+ severity = models.TextField(choices=Severity, null=True, default=None)
name = models.TextField(null=True, blank=True)
description = models.TextField(null=True, blank=True)
diff --git a/products/error_tracking/backend/presentation/views/issues.py b/products/error_tracking/backend/presentation/views/issues.py
index 05cbfe8702d3..c5acea45b917 100644
--- a/products/error_tracking/backend/presentation/views/issues.py
+++ b/products/error_tracking/backend/presentation/views/issues.py
@@ -20,6 +20,7 @@ from posthog.models.activity_logging.activity_page import activity_page_response
from products.error_tracking.backend.facade import (
api as facade_api,
+ contracts,
issues as issues_facade,
)
from products.error_tracking.backend.presentation.pagination import paginate_via_facade
@@ -36,6 +37,14 @@ logger = structlog.get_logger(__name__)
WRITABLE_ISSUE_STATUSES = ["active", "resolved", "suppressed"]
+@extend_schema_field(
+ {"type": "string", "enum": list(contracts.ERROR_TRACKING_ISSUE_SEVERITIES)},
+ component_name="ErrorTrackingIssueSeverity",
+)
+class ErrorTrackingIssueSeverityField(serializers.ChoiceField):
+ pass
+
+
class ErrorTrackingIssueAssigneeReadSerializer(serializers.Serializer):
# User assignees carry an integer id, role assignees a UUID string. `CharField` would
# coerce the user id to a string, which the frontend assignee resolver compares with
@@ -58,6 +67,11 @@ class ErrorTrackingIssueReadSerializer(serializers.Serializer):
id = serializers.UUIDField()
status = serializers.CharField()
+ severity = ErrorTrackingIssueSeverityField(
+ choices=contracts.ERROR_TRACKING_ISSUE_SEVERITIES,
+ allow_null=True,
+ help_text="Issue severity, or null when no severity is assigned.",
+ )
name = serializers.CharField(allow_null=True)
description = serializers.CharField(allow_null=True)
first_seen = serializers.DateTimeField(allow_null=True)
@@ -72,6 +86,12 @@ class ErrorTrackingIssueWriteSerializer(serializers.Serializer):
required=False,
help_text="Issue status to set. Deprecated archived and pending_release values are rejected.",
)
+ severity = ErrorTrackingIssueSeverityField(
+ choices=contracts.ERROR_TRACKING_ISSUE_SEVERITIES,
+ required=False,
+ allow_null=True,
+ help_text="Issue severity to set, or null to remove the assigned severity.",
+ )
name = serializers.CharField(
required=False,
allow_null=True,
diff --git a/products/error_tracking/backend/tests/api/test_error_tracking_api.py b/products/error_tracking/backend/tests/api/test_error_tracking_api.py
index 2175f25b9f69..0868476fa62c 100644
--- a/products/error_tracking/backend/tests/api/test_error_tracking_api.py
+++ b/products/error_tracking/backend/tests/api/test_error_tracking_api.py
@@ -128,6 +128,7 @@ class TestErrorTracking(APIBaseTest):
"cohort": None,
"description": None,
"status": "active",
+ "severity": None,
"assignee": None,
"first_seen": "2025-01-01T00:00:00Z",
"external_issues": [],
@@ -161,7 +162,8 @@ class TestErrorTracking(APIBaseTest):
issue = self.create_issue(["fingerprint"])
response = self.client.patch(
- f"/api/environments/{self.team.id}/error_tracking/issues/{issue.id}", data={"status": "resolved"}
+ f"/api/environments/{self.team.id}/error_tracking/issues/{issue.id}",
+ data={"status": "resolved", "severity": "high"},
)
issue.refresh_from_db()
@@ -172,11 +174,13 @@ class TestErrorTracking(APIBaseTest):
"cohort": None,
"description": None,
"status": "resolved",
+ "severity": "high",
"assignee": None,
"first_seen": "2025-01-01T00:00:00Z",
"external_issues": [],
}
assert issue.status == ErrorTrackingIssue.Status.RESOLVED
+ assert issue.severity == ErrorTrackingIssue.Severity.HIGH
self._assert_logs_the_activity(
issue.id,
@@ -192,7 +196,14 @@ class TestErrorTracking(APIBaseTest):
"before": "active",
"field": "status",
"type": "ErrorTrackingIssue",
- }
+ },
+ {
+ "action": "changed",
+ "after": "high",
+ "before": None,
+ "field": "severity",
+ "type": "ErrorTrackingIssue",
+ },
],
"name": issue.name,
"short_id": None,
diff --git a/products/error_tracking/frontend/generated/api.schemas.ts b/products/error_tracking/frontend/generated/api.schemas.ts
index 255ff2210723..2f9920321c79 100644
--- a/products/error_tracking/frontend/generated/api.schemas.ts
+++ b/products/error_tracking/frontend/generated/api.schemas.ts
@@ -626,6 +626,16 @@ export interface PatchedErrorTrackingGroupingRuleApi {
readonly updated_at?: string
}
+export type ErrorTrackingIssueSeverityApi =
+ (typeof ErrorTrackingIssueSeverityApi)[keyof typeof ErrorTrackingIssueSeverityApi]
+
+export const ErrorTrackingIssueSeverityApi = {
+ Low: 'low',
+ Medium: 'medium',
+ High: 'high',
+ Critical: 'critical',
+} as const
+
export interface ErrorTrackingIssueAssigneeReadApi {
readonly id: number | string | null
type: string
@@ -642,6 +652,8 @@ export interface ErrorTrackingIssueCohortReadApi {
export interface ErrorTrackingIssueReadApi {
id: string
status: string
+ /** Issue severity, or null when no severity is assigned. */
+ severity: ErrorTrackingIssueSeverityApi | null
/** @nullable */
name: string | null
/** @nullable */
@@ -683,6 +695,8 @@ export interface ErrorTrackingIssueWriteApi {
* * `resolved` - resolved
* * `suppressed` - suppressed */
status?: ErrorTrackingIssueWriteStatusEnumApi
+ /** Issue severity to set, or null to remove the assigned severity. */
+ severity?: ErrorTrackingIssueSeverityApi | null
/**
* Optional issue display name.
* @nullable
@@ -702,6 +716,8 @@ export interface PatchedErrorTrackingIssueWriteApi {
* * `resolved` - resolved
* * `suppressed` - suppressed */
status?: ErrorTrackingIssueWriteStatusEnumApi
+ /** Issue severity to set, or null to remove the assigned severity. */
+ severity?: ErrorTrackingIssueSeverityApi | null
/**
* Optional issue display name.
* @nullable
@@ -720,6 +736,8 @@ export interface PatchedErrorTrackingIssueWriteApi {
export interface PatchedErrorTrackingIssueReadApi {
id?: string
status?: string
+ /** Issue severity, or null when no severity is assigned. */
+ severity?: ErrorTrackingIssueSeverityApi | null
/** @nullable */
name?: string | null
/** @nullable */
diff --git a/products/error_tracking/frontend/generated/api.zod.ts b/products/error_tracking/frontend/generated/api.zod.ts
index 2ade6536c597..36f7202f41e3 100644
--- a/products/error_tracking/frontend/generated/api.zod.ts
+++ b/products/error_tracking/frontend/generated/api.zod.ts
@@ -232,6 +232,10 @@ export const ErrorTrackingIssuesUpdateBody = /* @__PURE__ */ zod.object({
.describe(
'Issue status to set. Deprecated archived and pending_release values are rejected.\n\n\* `active` - active\n\* `resolved` - resolved\n\* `suppressed` - suppressed'
),
+ severity: zod
+ .union([zod.enum(['low', 'medium', 'high', 'critical']), zod.null()])
+ .optional()
+ .describe('Issue severity to set, or null to remove the assigned severity.'),
name: zod.string().nullish().describe('Optional issue display name.'),
description: zod.string().nullish().describe('Optional issue description.'),
})
@@ -244,6 +248,10 @@ export const ErrorTrackingIssuesPartialUpdateBody = /* @__PURE__ */ zod.object({
.describe(
'Issue status to set. Deprecated archived and pending_release values are rejected.\n\n\* `active` - active\n\* `resolved` - resolved\n\* `suppressed` - suppressed'
),
+ severity: zod
+ .union([zod.enum(['low', 'medium', 'high', 'critical']), zod.null()])
+ .optional()
+ .describe('Issue severity to set, or null to remove the assigned severity.'),
name: zod.string().nullish().describe('Optional issue display name.'),
description: zod.string().nullish().describe('Optional issue description.'),
})
@@ -252,6 +260,10 @@ export const ErrorTrackingIssuesAssignPartialUpdateBody = /* @__PURE__ */ zod
.object({
id: zod.uuid().optional(),
status: zod.string().optional(),
+ severity: zod
+ .union([zod.enum(['low', 'medium', 'high', 'critical']), zod.null()])
+ .optional()
+ .describe('Issue severity, or null when no severity is assigned.'),
name: zod.string().nullish(),
description: zod.string().nullish(),
first_seen: zod.iso.datetime({ offset: true }).nullish(),
@@ -308,6 +320,9 @@ export const ErrorTrackingIssuesCohortUpdateBody = /* @__PURE__ */ zod
.object({
id: zod.uuid(),
status: zod.string(),
+ severity: zod
+ .union([zod.enum(['low', 'medium', 'high', 'critical']), zod.null()])
+ .describe('Issue severity, or null when no severity is assigned.'),
name: zod.string().nullable(),
description: zod.string().nullable(),
first_seen: zod.iso.datetime({ offset: true }).nullable(),
@@ -381,6 +396,9 @@ export const ErrorTrackingIssuesBulkCreateBody = /* @__PURE__ */ zod
.object({
id: zod.uuid(),
status: zod.string(),
+ severity: zod
+ .union([zod.enum(['low', 'medium', 'high', 'critical']), zod.null()])
+ .describe('Issue severity, or null when no severity is assigned.'),
name: zod.string().nullable(),
description: zod.string().nullable(),
first_seen: zod.iso.datetime({ offset: true }).nullable(),
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 12f1928f8c71..774a8e20cfda 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -27660,12 +27660,24 @@ export namespace Schemas {
includeSparkline?: boolean;
}
+ export type ErrorTrackingIssueSeverity = typeof ErrorTrackingIssueSeverity[keyof typeof ErrorTrackingIssueSeverity];
+
+
+ export const ErrorTrackingIssueSeverity = {
+ Low: 'low',
+ Medium: 'medium',
+ High: 'high',
+ Critical: 'critical',
+ } as const;
+
/**
* Read-only serializer for issue contract types returned by the facade.
*/
export interface ErrorTrackingIssueRead {
id: string;
status: string;
+ /** Issue severity, or null when no severity is assigned. */
+ severity: ErrorTrackingIssueSeverity | null;
/** @nullable */
name: string | null;
/** @nullable */
@@ -27739,6 +27751,8 @@ export namespace Schemas {
* * `resolved` - resolved
* * `suppressed` - suppressed */
status?: ErrorTrackingIssueWriteStatusEnum;
+ /** Issue severity to set, or null to remove the assigned severity. */
+ severity?: ErrorTrackingIssueSeverity | null;
/**
* Optional issue display name.
* @nullable
@@ -54316,6 +54330,8 @@ export namespace Schemas {
export interface PatchedErrorTrackingIssueRead {
id?: string;
status?: string;
+ /** Issue severity, or null when no severity is assigned. */
+ severity?: ErrorTrackingIssueSeverity | null;
/** @nullable */
name?: string | null;
/** @nullable */
@@ -54334,6 +54350,8 @@ export namespace Schemas {
* * `resolved` - resolved
* * `suppressed` - suppressed */
status?: ErrorTrackingIssueWriteStatusEnum;
+ /** Issue severity to set, or null to remove the assigned severity. */
+ severity?: ErrorTrackingIssueSeverity | null;
/**
* Optional issue display name.
* @nullable
diff --git a/services/mcp/src/generated/error_tracking/api.ts b/services/mcp/src/generated/error_tracking/api.ts
index 226b82faa874..075ee6631e66 100644
--- a/services/mcp/src/generated/error_tracking/api.ts
+++ b/services/mcp/src/generated/error_tracking/api.ts
@@ -6207,6 +6207,10 @@ export const ErrorTrackingIssuesPartialUpdateBody = /* @__PURE__ */ zod.object({
.describe(
'Issue status to set. Deprecated archived and pending_release values are rejected.\n\n\* `active` - active\n\* `resolved` - resolved\n\* `suppressed` - suppressed'
),
+ severity: zod
+ .union([zod.enum(['low', 'medium', 'high', 'critical']), zod.null()])
+ .optional()
+ .describe('Issue severity to set, or null to remove the assigned severity.'),
name: zod.string().nullish().describe('Optional issue display name.'),
description: zod.string().nullish().describe('Optional issue description.'),
})
diff --git a/services/mcp/src/tools/generated/error_tracking.ts b/services/mcp/src/tools/generated/error_tracking.ts
index 6366810730d5..adb3eff96332 100644
--- a/services/mcp/src/tools/generated/error_tracking.ts
+++ b/services/mcp/src/tools/generated/error_tracking.ts
@@ -295,6 +295,9 @@ const errorTrackingIssuesPartialUpdate = (): ToolBase<
if (params.status !== undefined) {
body['status'] = params.status
}
+ if (params.severity !== undefined) {
+ body['severity'] = params.severity
+ }
if (params.name !== undefined) {
body['name'] = params.name
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-issues-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-issues-partial-update.json
index 1d623256733c..1bc8a9b15331 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-issues-partial-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-issues-partial-update.json
@@ -26,6 +26,18 @@
],
"description": "Optional issue display name."
},
+ "severity": {
+ "anyOf": [
+ {
+ "enum": ["low", "medium", "high", "critical"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Issue severity to set, or null to remove the assigned severity."
+ },
"status": {
"description": "Issue status to set. Deprecated archived and pending_release values are rejected.\n\n* `active` - active\n* `resolved` - resolved\n* `suppressed` - suppressed",
"enum": ["active", "resolved", "suppressed"],