Skip to content

Alert emails now contain the Org name #1555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/webapp/app/v3/services/alerts/deliverAlert.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export class DeliverAlertService extends BaseService {
environment: alert.environment.slug,
error: createJsonErrorObject(taskRunError),
attemptLink: `${env.APP_ORIGIN}/projects/v3/${alert.project.externalRef}/runs/${alert.taskRunAttempt.taskRun.friendlyId}`,
organization: alert.project.organization.title,
});
} else {
logger.error("[DeliverAlert] Task run attempt not found", {
Expand All @@ -244,6 +245,7 @@ export class DeliverAlertService extends BaseService {
environment: alert.environment.slug,
error: createJsonErrorObject(taskRunError),
runLink: `${env.APP_ORIGIN}/projects/v3/${alert.project.externalRef}/runs/${alert.taskRun.friendlyId}`,
organization: alert.project.organization.title,
});
} else {
logger.error("[DeliverAlert] Task run not found", {
Expand Down Expand Up @@ -276,6 +278,7 @@ export class DeliverAlertService extends BaseService {
failedAt: alert.workerDeployment.failedAt ?? new Date(),
error: preparedError,
deploymentLink: `${env.APP_ORIGIN}/projects/v3/${alert.project.externalRef}/deployments/${alert.workerDeployment.shortCode}`,
organization: alert.project.organization.title,
});
} else {
logger.error("[DeliverAlert] Worker deployment not found", {
Expand All @@ -296,6 +299,7 @@ export class DeliverAlertService extends BaseService {
deployedAt: alert.workerDeployment.deployedAt ?? new Date(),
deploymentLink: `${env.APP_ORIGIN}/projects/v3/${alert.project.externalRef}/deployments/${alert.workerDeployment.shortCode}`,
taskCount: alert.workerDeployment.worker?.tasks.length ?? 0,
organization: alert.project.organization.title,
});
} else {
logger.error("[DeliverAlert] Worker deployment not found", {
Expand Down
15 changes: 13 additions & 2 deletions internal-packages/emails/emails/alert-attempt-failure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const AlertAttemptEmailSchema = z.object({
stackTrace: z.string().optional(),
}),
attemptLink: z.string().url(),
organization: z.string(),
});

const previewDefaults = {
Expand All @@ -44,15 +45,24 @@ const previewDefaults = {
};

export default function Email(props: z.infer<typeof AlertAttemptEmailSchema>) {
const { taskIdentifier, fileName, exportName, version, environment, error, attemptLink } = {
const {
taskIdentifier,
fileName,
exportName,
version,
environment,
error,
attemptLink,
organization,
} = {
...previewDefaults,
...props,
};

return (
<Html>
<Head />
<Preview>{`[${version}.${environment} ${taskIdentifier}] ${error.message}`}</Preview>
<Preview>{`${organization}: [${version}.${environment} ${taskIdentifier}] ${error.message}`}</Preview>
<Body style={main}>
<Container style={container}>
<Text style={h1}>There's been an error on `{taskIdentifier}`</Text>
Expand All @@ -61,6 +71,7 @@ export default function Email(props: z.infer<typeof AlertAttemptEmailSchema>) {
<Text style={paragraphTight}>Function: {exportName}()</Text>
<Text style={paragraphTight}>Version: {version}</Text>
<Text style={paragraphTight}>Environment: {environment}</Text>
<Text style={paragraphTight}>Organization: {organization}</Text>

<Text style={paragraphLight}>{error.message}</Text>
{error.stackTrace && (
Expand Down
6 changes: 5 additions & 1 deletion internal-packages/emails/emails/alert-run-failure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const AlertRunEmailSchema = z.object({
stackTrace: z.string().optional(),
}),
runLink: z.string().url(),
organization: z.string(),
});

type AlertRunEmailProps = z.infer<typeof AlertRunEmailSchema>;
Expand All @@ -49,6 +50,7 @@ const previewDefaults: AlertRunEmailProps = {
stackTrace: "Error stack trace",
},
runLink: "https://trigger.dev",
organization: "my-organization",
};

export default function Email(props: AlertRunEmailProps) {
Expand All @@ -62,6 +64,7 @@ export default function Email(props: AlertRunEmailProps) {
environment,
error,
runLink,
organization,
} = {
...previewDefaults,
...props,
Expand All @@ -70,10 +73,11 @@ export default function Email(props: AlertRunEmailProps) {
return (
<Html>
<Head />
<Preview>{`[${version}.${environment} ${taskIdentifier}] ${error.message}`}</Preview>
<Preview>{`${organization}: [${version}.${environment} ${taskIdentifier}] ${error.message}`}</Preview>
<Body style={main}>
<Container style={container}>
<Text style={h1}>Run `{runId}` failed</Text>
<Text style={paragraphTight}>Organization: {organization}</Text>
<Text style={paragraphTight}>Project: {project}</Text>
<Text style={paragraphTight}>Task ID: {taskIdentifier}</Text>
<Text style={paragraphTight}>Filename: {fileName}</Text>
Expand Down
6 changes: 4 additions & 2 deletions internal-packages/emails/emails/deployment-failure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const AlertDeploymentFailureEmailSchema = z.object({
email: z.literal("alert-deployment-failure"),
version: z.string(),
environment: z.string(),
organization: z.string(),
shortCode: z.string(),
failedAt: z.date(),
error: z.object({
Expand All @@ -31,6 +32,7 @@ export const AlertDeploymentFailureEmailSchema = z.object({
const previewDefaults = {
version: "v1",
environment: "production",
organization: "My Organization",
shortCode: "abc123",
failedAt: new Date().toISOString(),
error: {
Expand All @@ -41,15 +43,15 @@ const previewDefaults = {
};

export default function Email(props: z.infer<typeof AlertDeploymentFailureEmailSchema>) {
const { version, environment, shortCode, failedAt, error, deploymentLink } = {
const { version, environment, organization, shortCode, failedAt, error, deploymentLink } = {
...previewDefaults,
...props,
};

return (
<Html>
<Head />
<Preview>{`Deployment ${version} [${environment}] failed: ${error.name}`}</Preview>
<Preview>{`[${organization}] Deployment ${version} [${environment}] failed: ${error.name}`}</Preview>
<Body style={main}>
<Container style={container}>
<Text style={h1}>{`An error occurred deploying ${version} in ${environment}`}</Text>
Expand Down
6 changes: 4 additions & 2 deletions internal-packages/emails/emails/deployment-success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const AlertDeploymentSuccessEmailSchema = z.object({
email: z.literal("alert-deployment-success"),
version: z.string(),
environment: z.string(),
organization: z.string(),
shortCode: z.string(),
deployedAt: z.date(),
taskCount: z.number(),
Expand All @@ -17,22 +18,23 @@ export const AlertDeploymentSuccessEmailSchema = z.object({
const previewDefaults = {
version: "v1",
environment: "production",
organization: "My Organization",
shortCode: "abc123",
deployedAt: new Date().toISOString(),
taskCount: 3,
deploymentLink: "https://trigger.dev",
};

export default function Email(props: z.infer<typeof AlertDeploymentSuccessEmailSchema>) {
const { version, environment, shortCode, deployedAt, taskCount, deploymentLink } = {
const { version, environment, organization, shortCode, deployedAt, taskCount, deploymentLink } = {
...previewDefaults,
...props,
};

return (
<Html>
<Head />
<Preview>{`Deployment ${version} [${environment}] succeeded`}</Preview>
<Preview>{`[${organization}] Deployment ${version} [${environment}] succeeded`}</Preview>
<Body style={main}>
<Container style={container}>
<Text
Expand Down
Loading