Commit 303377c 1 parent b7d07ed commit 303377c Copy full SHA for 303377c
File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { Status } from './statusCodes'
8
8
import { ApiError } from './errors'
9
9
import type { UserDetails } from 'prisma-client'
10
10
import { ServerEnvironment } from '../env.server'
11
+ import { assertNever } from './assertNever'
11
12
12
13
// these need to be decimal colors (for 'discord-webhook-node')
13
14
const colors : Record < DiscordMessageType , number > = {
@@ -43,6 +44,7 @@ export function sendDiscordMessage(
43
44
44
45
const fields : Record < string , string > = {
45
46
User : `${ user . name ?? 'Unknown User' } (${ user . email ?? 'Unknown Email' } )` ,
47
+ Environment : getEnvironmentText ( ) ,
46
48
...( messageDescriptor . fields ?? { } ) ,
47
49
}
48
50
@@ -70,3 +72,18 @@ function getWebhook(type: DiscordWebhookType) {
70
72
function createDiscordWebhook ( url : string ) {
71
73
return new Webhook ( url )
72
74
}
75
+
76
+ function getEnvironmentText ( ) {
77
+ switch ( ServerEnvironment . environment ) {
78
+ case 'local' :
79
+ return 'Local'
80
+ case 'stage' :
81
+ return 'Staging'
82
+ case 'prod' :
83
+ return 'Production'
84
+ case 'test' :
85
+ return 'Test'
86
+ default :
87
+ assertNever ( ServerEnvironment . environment )
88
+ }
89
+ }
You can’t perform that action at this time.
0 commit comments