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

Conversation

samejr
Copy link
Member

@samejr samejr commented Dec 12, 2024

Added the Org name to the alert emails. This was from a customer with multiple orgs who couldn't tell where the errors were coming from easily.

Org name has been added to:

  • attempt failed email
  • run failed email
  • deployment failed email
  • deployment succeeded email

Summary by CodeRabbit

  • New Features

    • Added an organization property to various email schemas, enhancing email content with organizational context.
    • Updated email previews to include the organization name in the message format for alert attempts, runs, and deployments (both success and failure).
    • Enhanced alert delivery methods to include the organization in notifications sent via email, webhook, and Slack.
  • Bug Fixes

    • Ensured consistent display of the organization name across all relevant email notifications.

Copy link

changeset-bot bot commented Dec 12, 2024

⚠️ No Changeset found

Latest commit: 66ab41a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/webapp/app/v3/services/alerts/deliverAlert.server.ts

Oops! Something went wrong! :(

ESLint: 8.45.0

ESLint couldn't find the config "custom" to extend from. Please check that the name of the config is correct.

The config "custom" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

This pull request introduces a new property, organization, to several email schemas and components related to alert notifications. The organization property is defined as a string and is integrated into the AlertAttemptEmailSchema, AlertRunEmailSchema, AlertDeploymentFailureEmailSchema, and AlertDeploymentSuccessEmailSchema. Updates are made to the respective Email components to include this new property in their props, along with modifications to the email content to display the organization name in the message format.

Changes

File Path Change Summary
internal-packages/emails/emails/alert-attempt-failure.tsx Added organization: z.string() to AlertAttemptEmailSchema, updated Email props destructuring, modified Preview to include organization in the message.
internal-packages/emails/emails/alert-run-failure.tsx Added organization: z.string() to AlertRunEmailSchema, updated previewDefaults to include organization: "my-organization", modified Email props destructuring and Preview content.
internal-packages/emails/emails/deployment-failure.tsx Added organization: z.string() to AlertDeploymentFailureEmailSchema, updated previewDefaults to include organization: "My Organization", modified Email props destructuring and Preview content.
internal-packages/emails/emails/deployment-success.tsx Added organization: z.string() to AlertDeploymentSuccessEmailSchema, updated previewDefaults to include organization: "My Organization", modified Email props destructuring and Preview content.
apps/webapp/app/v3/services/alerts/deliverAlert.server.ts Updated sendEmail, sendWebhook, and sendSlack methods in DeliverAlertService to include organization in payloads, enhanced error handling in sendSlack.

Possibly related PRs

Suggested reviewers

  • matt-aitken

Poem

🐰 In the meadow where emails fly,
A new name joins the sky,
"Organization" hops in cheer,
To share the news far and near!
With every alert, a tale to tell,
Of deployments and runs, all is well! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (6)
internal-packages/emails/emails/deployment-success.tsx (1)

Line range hint 42-44: Add organization name to the email body for consistency

While the organization is shown in the preview, it should also be displayed in the email body for better context, similar to how it's shown in other alert emails.

 <Text
   style={h1}
->{`Version ${version} successfully deployed ${taskCount} tasks in ${environment}`}</Text>
+>{`[${organization}] Version ${version} successfully deployed ${taskCount} tasks in ${environment}`}</Text>
internal-packages/emails/emails/deployment-failure.tsx (1)

Line range hint 57-58: Add organization name to the email body for consistency

The organization name should be displayed in the email body to maintain consistency with other alert emails.

-<Text style={h1}>{`An error occurred deploying ${version} in ${environment}`}</Text>
+<Text style={h1}>{`[${organization}] An error occurred deploying ${version} in ${environment}`}</Text>
internal-packages/emails/emails/alert-attempt-failure.tsx (3)

65-65: Standardize preview text format across all alert emails

The preview text format differs from other alert emails. Consider standardizing the format:

-<Preview>{`${organization}: [${version}.${environment} ${taskIdentifier}] ${error.message}`}</Preview>
+<Preview>{`[${organization}] ${taskIdentifier} [${environment}] ${error.message}`}</Preview>

48-57: Simplify props destructuring for better readability

The current multi-line props destructuring can be simplified.

-  const {
-    taskIdentifier,
-    fileName,
-    exportName,
-    version,
-    environment,
-    error,
-    attemptLink,
-    organization,
-  } = {
+  const { taskIdentifier, fileName, exportName, version, environment, error, attemptLink, organization } = {

Organization implementation is inconsistent across email templates

deployment-success.tsx and deployment-failure.tsx use organization in preview text as [${organization}]
invite.tsx uses organization name in preview as You've been invited to ${orgName}
alert-attempt-failure.tsx and alert-run-failure.tsx have the organization field in schema but preview text implementation is not visible in the first 50 lines
• Some templates use "organization" while others use "orgName" as the property name

🔗 Analysis chain

Line range hint 1-1: Verify organization name implementation across all email templates

Let's ensure the organization name has been consistently implemented across all email templates.


The previous results confirmed that all email schemas include the organization field, but we need to verify the actual usage of the organization name in the email templates for consistency. Let's check how the organization name is displayed in the preview text and email body across all templates.


Let's verify the consistency of how organization is used in email subjects and preview texts. The previous results showed schema definitions and mock data, but we need to check the actual implementation in the email templates.


Let's try a broader search to see the email template implementations, as the previous search patterns might have missed the actual usage patterns. This will help us verify how the organization name is being used in the email content.


Let's examine the actual content of these email template files to verify the organization implementation, as our previous pattern matching attempts didn't yield the expected results. This will show us the beginning of each file where the email components are typically defined.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if organization field is added to all email schemas and previews
echo "Checking email templates for organization implementation..."
rg -l "AlertAttemptEmailSchema|AlertRunEmailSchema|AlertDeploymentFailureEmailSchema|AlertDeploymentSuccessEmailSchema" internal-packages/emails/emails/
rg "organization: z.string" internal-packages/emails/emails/
rg "\[${organization}\]|\${organization}:" internal-packages/emails/emails/

Length of output: 1075


Script:

#!/bin/bash
# Check for organization name usage in email templates
echo "Checking organization name usage in email templates..."
rg -A 2 "\$\{organization\}" internal-packages/emails/emails/
rg -A 2 "organization:" internal-packages/emails/emails/

Length of output: 1865


Script:

#!/bin/bash
# Check email preview text and subject implementations
echo "Checking email preview and subject implementations..."
rg -B 2 -A 4 "subject:|previewText:" internal-packages/emails/emails/

Length of output: 188


Script:

#!/bin/bash
# Check email template implementations more broadly
echo "Checking email template implementations..."
rg -A 10 "export const.*Email = " internal-packages/emails/emails/

Length of output: 163


Script:

#!/bin/bash
# Check content of email template files
echo "Checking content of email template files..."
for file in $(find internal-packages/emails/emails/ -name "*.tsx"); do
    echo "=== $file ==="
    head -n 50 "$file"
    echo -e "\n"
done

Length of output: 13900

internal-packages/emails/emails/alert-run-failure.tsx (1)

76-80: Consider improving the preview line readability

While the organization name addition is good, the preview line might be getting too dense. Consider breaking it into two parts:

-      <Preview>{`${organization}: [${version}.${environment} ${taskIdentifier}] ${error.message}`}</Preview>
+      <Preview>{`${organization} - ${error.message}\n[${version}.${environment} ${taskIdentifier}]`}</Preview>

The organization display in the email body is well-implemented, with good placement and consistent styling.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebd9767 and bc45b88.

📒 Files selected for processing (4)
  • internal-packages/emails/emails/alert-attempt-failure.tsx (3 hunks)
  • internal-packages/emails/emails/alert-run-failure.tsx (4 hunks)
  • internal-packages/emails/emails/deployment-failure.tsx (3 hunks)
  • internal-packages/emails/emails/deployment-success.tsx (2 hunks)
🔇 Additional comments (3)
internal-packages/emails/emails/alert-run-failure.tsx (3)

33-33: LGTM: Schema change correctly adds organization field

The addition of the required organization field to the schema is well-implemented and aligns with the PR objectives.


53-53: LGTM: Preview default value is appropriate

The default value "my-organization" is descriptive and follows the existing pattern of preview defaults.


67-67: LGTM: Props destructuring properly includes organization

The organization prop is correctly destructured and follows the existing code style.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
apps/webapp/app/v3/services/alerts/deliverAlert.server.ts (1)

Line range hint 737-737: Consider adding organization name to Slack message context

While the Slack messages include the project name, consider adding the organization name to the context line for consistency with email alerts and better clarity in multi-org environments. For example:

-text: `${runId} | ${taskIdentifier} | ${version}.${environment} | ${alert.project.name}`,
+text: `${runId} | ${taskIdentifier} | ${version}.${environment} | ${alert.project.organization.title} / ${alert.project.name}`,

Also applies to: 800-800, 896-896, 970-970

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc45b88 and 66ab41a.

📒 Files selected for processing (1)
  • apps/webapp/app/v3/services/alerts/deliverAlert.server.ts (4 hunks)
🔇 Additional comments (2)
apps/webapp/app/v3/services/alerts/deliverAlert.server.ts (2)

222-222: LGTM: Organization name consistently added to all email alerts

The changes successfully add the organization name to all types of alert emails (attempt, run, deployment failure, and deployment success) in a consistent manner.

Also applies to: 248-248, 281-281, 302-302


Line range hint 1051-1074: LGTM: Robust error handling and helper methods

The error handling is comprehensive, covering various Slack API error types with appropriate logging and retry logic. The helper methods for text truncation and formatting are well-implemented with proper length checks and logging.

@ericallam ericallam merged commit f0182ab into main Dec 13, 2024
7 of 8 checks passed
@ericallam ericallam deleted the alerts-contain-org-names branch December 13, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants