Skip to content

Commit 303377c

Browse files
authored
feat(discord): add environment data to discord messages (#6676)
This PR adds environment data to the messages that are being sent to Discord <img width=400 src="https://github.com/user-attachments/assets/52702eb5-4e0e-4714-9d4d-60432d4ea99b"></img> **Manual Tests:** I hereby swear that: - [X] I opened a hydrogen project and it loaded - [X] I could navigate to various routes in Play mode
1 parent b7d07ed commit 303377c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

utopia-remix/app/util/discordWebhookUtils.ts

+17
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Status } from './statusCodes'
88
import { ApiError } from './errors'
99
import type { UserDetails } from 'prisma-client'
1010
import { ServerEnvironment } from '../env.server'
11+
import { assertNever } from './assertNever'
1112

1213
// these need to be decimal colors (for 'discord-webhook-node')
1314
const colors: Record<DiscordMessageType, number> = {
@@ -43,6 +44,7 @@ export function sendDiscordMessage(
4344

4445
const fields: Record<string, string> = {
4546
User: `${user.name ?? 'Unknown User'} (${user.email ?? 'Unknown Email'})`,
47+
Environment: getEnvironmentText(),
4648
...(messageDescriptor.fields ?? {}),
4749
}
4850

@@ -70,3 +72,18 @@ function getWebhook(type: DiscordWebhookType) {
7072
function createDiscordWebhook(url: string) {
7173
return new Webhook(url)
7274
}
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+
}

0 commit comments

Comments
 (0)