@@ -13,12 +13,16 @@ class SourceProduct(models.TextChoices):
1313 GITHUB = "github" , "GitHub"
1414 LINEAR = "linear" , "Linear"
1515 ZENDESK = "zendesk" , "Zendesk"
16+ ERROR_TRACKING = "error_tracking" , "Error tracking"
1617
1718 class SourceType (models .TextChoices ):
1819 SESSION_ANALYSIS_CLUSTER = "session_analysis_cluster" , "Session analysis cluster"
1920 EVALUATION = "evaluation" , "Evaluation"
2021 ISSUE = "issue" , "Issue"
2122 TICKET = "ticket" , "Ticket"
23+ ISSUE_CREATED = "issue_created" , "Issue created"
24+ ISSUE_REOPENED = "issue_reopened" , "Issue reopened"
25+ ISSUE_SPIKING = "issue_spiking" , "Issue spiking"
2226
2327 team = models .ForeignKey ("posthog.Team" , on_delete = models .CASCADE , related_name = "signal_source_configs" )
2428 source_product = models .CharField (max_length = 100 , choices = SourceProduct .choices )
@@ -29,6 +33,23 @@ class SourceType(models.TextChoices):
2933 updated_at = models .DateTimeField (auto_now = True )
3034 created_by = models .ForeignKey ("posthog.User" , on_delete = models .SET_NULL , null = True , blank = True )
3135
36+ @classmethod
37+ def is_source_enabled (cls , team_id : int , source_product : str , source_type : str ) -> bool :
38+ """Check whether a given signal source is enabled for a team.
39+
40+ LLM analytics signals are always allowed (gated in llma evals workflows). TODO - this should be moved here.
41+ For everything else, the team must have a SignalSourceConfig row with enabled=True.
42+ """
43+ if source_product == cls .SourceProduct .LLM_ANALYTICS :
44+ return True
45+
46+ return cls .objects .filter (
47+ team_id = team_id ,
48+ source_product = source_product ,
49+ source_type = source_type ,
50+ enabled = True ,
51+ ).exists ()
52+
3253 class Meta :
3354 constraints = [
3455 models .UniqueConstraint (
0 commit comments