Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed May 6, 2024
1 parent f64763b commit 0c6c094
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
10 changes: 9 additions & 1 deletion apps/vpnmanager/sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import * as Sentry from "@sentry/nextjs";

const options = {
dsn: process.env.SENTRY_DSN,
environment: process.env.SENTRY_ENV ?? "local",
tracesSampleRate: 1,
}

Sentry.init(options);

export function initSentry() {
Sentry.init();
Sentry.init(options);
}
21 changes: 11 additions & 10 deletions apps/vpnmanager/src/lib/email/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ import * as Sentry from "@sentry/nextjs";
import { emailKeyTemplate } from "./templates";

interface MailSender {
recipient: string;
to: string;
key: string;
name: string;
}

export async function sendVpnKeyEmail({
recipient: to,
key,
name,
}: MailSender) {
export async function sendVpnKeyEmail({ to, key, name }: MailSender) {
try {
const sendGridApiKey = process.env.VPN_MANAGER_SENDGRID_API_KEY as string;
if (!sendGridApiKey) {
Expand All @@ -33,10 +29,15 @@ export async function sendVpnKeyEmail({
html: emailKeyTemplate(key, name),
};
await sgMail.send(message);
Sentry.captureMessage(
`Email sent to "${to}" ${emailKeyTemplate("*hidden*", name)}`,
"info",
);
Sentry.withScope((scope) => {
scope.setLevel("info");
scope.setUser({
id: to,
email: to,
});
scope.addAttachment({ filename: "email.html", data: emailKeyTemplate("*hidden*", name)})
Sentry.captureMessage("Outline key sent");
});
} catch (error) {
Sentry.captureException(error);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/vpnmanager/src/lib/email/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export function emailKeyTemplate(key: string, name: string) {
<li>Copy your Access key ${key}</li>
<li>Open the Outline client app. If your access key is auto-detected, tap 'Connect'. If your access key is not auto-detected, paste it in the field, then tap 'Connect'. You are good to go!</li>
</ol>
<p>NOTE: The same key can be used for multiple devices.</p>
</div>`;
}
2 changes: 1 addition & 1 deletion apps/vpnmanager/src/lib/processUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function processUser(item: SheetRow) {
}
}
await sendVpnKeyEmail({
recipient: user?.name ?? "",
to: user?.name ?? "",
key: user?.accessUrl ?? "",
name: item?.member ?? user?.name,
});
Expand Down

0 comments on commit 0c6c094

Please sign in to comment.