@@ -40,6 +40,7 @@ import { type ProjectAlertChannelType, type ProjectAlertType } from "@trigger.de
4040import { alertsRateLimiter } from "~/v3/alertsRateLimiter.server" ;
4141import { v3RunPath } from "~/utils/pathBuilder" ;
4242import { ApiRetrieveRunPresenter } from "~/presenters/v3/ApiRetrieveRunPresenter.server" ;
43+ import { environmentTitle } from "~/components/environments/EnvironmentLabel" ;
4344
4445type FoundAlert = Prisma . Result <
4546 typeof prisma . projectAlert ,
@@ -56,6 +57,12 @@ type FoundAlert = Prisma.Result<
5657 include : {
5758 lockedBy : true ;
5859 lockedToVersion : true ;
60+ runtimeEnvironment : {
61+ select : {
62+ type : true ;
63+ branchName : true ;
64+ } ;
65+ } ;
5966 } ;
6067 } ;
6168 workerDeployment : {
@@ -65,6 +72,12 @@ type FoundAlert = Prisma.Result<
6572 tasks : true ;
6673 } ;
6774 } ;
75+ environment : {
76+ select : {
77+ type : true ;
78+ branchName : true ;
79+ } ;
80+ } ;
6881 } ;
6982 } ;
7083 } ;
@@ -90,6 +103,12 @@ export class DeliverAlertService extends BaseService {
90103 include : {
91104 lockedBy : true ,
92105 lockedToVersion : true ,
106+ runtimeEnvironment : {
107+ select : {
108+ type : true ,
109+ branchName : true ,
110+ } ,
111+ } ,
93112 } ,
94113 } ,
95114 workerDeployment : {
@@ -99,6 +118,12 @@ export class DeliverAlertService extends BaseService {
99118 tasks : true ,
100119 } ,
101120 } ,
121+ environment : {
122+ select : {
123+ type : true ,
124+ branchName : true ,
125+ } ,
126+ } ,
102127 } ,
103128 } ,
104129 } ,
@@ -177,10 +202,9 @@ export class DeliverAlertService extends BaseService {
177202 runId : alert . taskRun . friendlyId ,
178203 taskIdentifier : alert . taskRun . taskIdentifier ,
179204 fileName : alert . taskRun . lockedBy ?. filePath ?? "Unknown" ,
180- exportName : alert . taskRun . lockedBy ?. exportName ?? "Unknown" ,
181205 version : alert . taskRun . lockedToVersion ?. version ?? "Unknown" ,
182206 project : alert . project . name ,
183- environment : alert . environment . slug ,
207+ environment : environmentTitle ( alert . taskRun . runtimeEnvironment ) ,
184208 error : createJsonErrorObject ( taskRunError ) ,
185209 runLink : `${ env . APP_ORIGIN } /projects/v3/${ alert . project . externalRef } /runs/${ alert . taskRun . friendlyId } ` ,
186210 organization : alert . project . organization . title ,
@@ -211,7 +235,7 @@ export class DeliverAlertService extends BaseService {
211235 email : "alert-deployment-failure" ,
212236 to : emailProperties . data . email ,
213237 version : alert . workerDeployment . version ,
214- environment : alert . environment . slug ,
238+ environment : environmentTitle ( alert . workerDeployment . environment ) ,
215239 shortCode : alert . workerDeployment . shortCode ,
216240 failedAt : alert . workerDeployment . failedAt ?? new Date ( ) ,
217241 error : preparedError ,
@@ -232,7 +256,7 @@ export class DeliverAlertService extends BaseService {
232256 email : "alert-deployment-success" ,
233257 to : emailProperties . data . email ,
234258 version : alert . workerDeployment . version ,
235- environment : alert . environment . slug ,
259+ environment : environmentTitle ( alert . workerDeployment . environment ) ,
236260 shortCode : alert . workerDeployment . shortCode ,
237261 deployedAt : alert . workerDeployment . deployedAt ?? new Date ( ) ,
238262 deploymentLink : `${ env . APP_ORIGIN } /projects/v3/${ alert . project . externalRef } /deployments/${ alert . workerDeployment . shortCode } ` ,
@@ -292,6 +316,7 @@ export class DeliverAlertService extends BaseService {
292316 id : alert . environment . id ,
293317 type : alert . environment . type ,
294318 slug : alert . environment . slug ,
319+ branchName : alert . environment . branchName ?? undefined ,
295320 } ,
296321 organization : {
297322 id : alert . project . organizationId ,
@@ -349,6 +374,7 @@ export class DeliverAlertService extends BaseService {
349374 id : alert . environment . id ,
350375 type : alert . environment . type ,
351376 slug : alert . environment . slug ,
377+ branchName : alert . environment . branchName ?? undefined ,
352378 } ,
353379 organization : {
354380 id : alert . project . organizationId ,
@@ -648,9 +674,8 @@ export class DeliverAlertService extends BaseService {
648674 const taskRunError = this . #getRunError( alert ) ;
649675 const error = createJsonErrorObject ( taskRunError ) ;
650676
651- const exportName = alert . taskRun . lockedBy ?. exportName ?? "Unknown" ;
652677 const version = alert . taskRun . lockedToVersion ?. version ?? "Unknown" ;
653- const environment = alert . environment . slug ;
678+ const environment = environmentTitle ( alert . taskRun . runtimeEnvironment ) ;
654679 const taskIdentifier = alert . taskRun . taskIdentifier ;
655680 const timestamp = alert . taskRun . completedAt ?? new Date ( ) ;
656681 const runId = alert . taskRun . friendlyId ;
@@ -664,7 +689,7 @@ export class DeliverAlertService extends BaseService {
664689 type : "section" ,
665690 text : {
666691 type : "mrkdwn" ,
667- text : `:rotating_light: Error in *${ exportName } * _<!date^${ Math . round (
692+ text : `:rotating_light: Error in *${ taskIdentifier } * _<!date^${ Math . round (
668693 timestamp . getTime ( ) / 1000
669694 ) } ^at {date_num} {time_secs}|${ timestamp . toLocaleString ( ) } >_`,
670695 } ,
0 commit comments