Skip to content

Open-source status page, incident response and uptime monitoring

chore: slack webhook support url (#957)

Maximilian Kaske9c9285d98fad
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 24e533a2e..366277501 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,7 +1,7 @@
{
"editor.codeActionsOnSave": {},
"editor.defaultFormatter": "biomejs.biome",
- "editor.formatOnSave": false,
+ "editor.formatOnSave": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
diff --git a/apps/web/.env.example b/apps/web/.env.example
index 0d92f6b84..af25d4340 100644
--- a/apps/web/.env.example
+++ b/apps/web/.env.example
@@ -72,6 +72,6 @@ AUTH_GITHUB_SECRET=
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
-PLAIN_API_KEY=
-
PAGERDUTY_APP_ID=
+
+SLACK_SUPPORT_WEBHOOK_URL=
diff --git a/apps/web/package.json b/apps/web/package.json
index 174df06db..05e3fd381 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -43,7 +43,6 @@
"@tailwindcss/container-queries": "0.1.1",
"@tailwindcss/typography": "0.5.10",
"@tanstack/react-table": "8.10.3",
- "@team-plain/typescript-sdk": "4.2.3",
"@tremor/react": "3.17.4",
"@trpc/client": "10.45.2",
"@trpc/next": "10.45.2",
diff --git a/apps/web/src/components/support/action.ts b/apps/web/src/components/support/action.ts
index effa263b8..694798e2f 100644
--- a/apps/web/src/components/support/action.ts
+++ b/apps/web/src/components/support/action.ts
@@ -1,71 +1,37 @@
"use server";
-import { PlainClient } from "@team-plain/typescript-sdk";
-
import { env } from "@/env";
-
import type { FormValues } from "./contact-form";
-const labelTypeIds = {
- bug: "lt_01HZDA8FCA0CMPCJ2YSTVE78XN",
- demo: "lt_01HZDA8N33R1A9AN97RGXPZ93F",
- feature: "lt_01HZDA8V56431V27GFDAVV58FX",
- question: "lt_01HZDA8XWTY0SWY4MKNY6F4EVK",
- security: "lt_01HZDA91M7KVR4529FHVHE18MG",
-};
-
-function getPriority(type: FormValues["type"], isBlocking: boolean) {
- if (type === "security") return 0;
- if (type === "bug" && isBlocking) return 1;
- return 2;
-}
-
-function isString(s: unknown): s is string {
- return typeof s === "string";
-}
-
-const client = new PlainClient({
- apiKey: env.PLAIN_API_KEY || "",
-});
-
-export async function handlePlainSupport(values: FormValues) {
- const upsertCustomerRes = await client.upsertCustomer({
- identifier: {
- emailAddress: values.email,
- },
- onCreate: {
- fullName: values.name,
- email: {
- email: values.email,
- isVerified: true,
- },
- },
- onUpdate: {},
- });
-
- if (upsertCustomerRes.error) {
- console.error(upsertCustomerRes.error);
- return { error: upsertCustomerRes.error.message };
+export async function handleSlackWebhookSupport(values: FormValues) {
+ console.log(env);
+ if (!env.SLACK_SUPPORT_WEBHOOK_URL) return { error: "Missing webhook URL." };
+
+ try {
+ await fetch(env.SLACK_SUPPORT_WEBHOOK_URL, {
+ method: "POST",
+ body: JSON.stringify({
+ blocks: [
+ {
+ type: "section",
+ text: {
+ type: "mrkdwn",
+ text: `*New Support Request!* [${process.env.NODE_ENV.toUpperCase()}]\n\n
+*Name:* ${values.name}\n
+*Type:* ${values.type}\n
+*Blocker:* ${values.blocker ? "Yes" : "No"}\n
+*Email:* ${values.email}\n
+*Message:* ${values.message}\n
+`,
+ },
+ },
+ ],
+ }),
+ });
+ } catch (e) {
+ console.log(e);
+ return { error: "Something went wrong. Please try again." };
}
- console.log(`Customer upserted ${upsertCustomerRes.data.customer.id}`);
-
- const createThreadRes = await client.createThread({
- customerIdentifier: {
- customerId: upsertCustomerRes.data.customer.id,
- },
- title: "Support request!",
- components: [{ componentText: { text: values.message } }],
- labelTypeIds: [labelTypeIds[values.type]].filter(isString),
- priority: getPriority(values.type, values.blocker),
- });
-
- if (createThreadRes.error) {
- console.error(createThreadRes.error);
- return { error: createThreadRes.error.message };
- }
-
- console.log(`Thread created ${createThreadRes.data.id}`);
-
return { error: null };
}
diff --git a/apps/web/src/components/support/contact-form.tsx b/apps/web/src/components/support/contact-form.tsx
index 9585384e5..155a360ea 100644
--- a/apps/web/src/components/support/contact-form.tsx
+++ b/apps/web/src/components/support/contact-form.tsx
@@ -25,7 +25,7 @@ import {
import { toast } from "@/lib/toast";
import { LoadingAnimation } from "../loading-animation";
-import { handlePlainSupport } from "./action";
+import { handleSlackWebhookSupport } from "./action";
export const types = [
{
@@ -77,10 +77,9 @@ export function ContactForm({
async function onSubmit(data: FormValues) {
startTransition(async () => {
- const result = await handlePlainSupport(data);
+ const result = await handleSlackWebhookSupport(data);
if (result.error) {
- console.error(result.error);
- toast.error("Something went wrong. Please try again.");
+ toast.error(result.error);
} else {
handleSubmit?.();
toast.success(
diff --git a/apps/web/src/env.ts b/apps/web/src/env.ts
index 5a3002423..0e9424301 100644
--- a/apps/web/src/env.ts
+++ b/apps/web/src/env.ts
@@ -23,8 +23,8 @@ export const env = createEnv({
CLICKHOUSE_URL: z.string(),
CLICKHOUSE_USERNAME: z.string(),
CLICKHOUSE_PASSWORD: z.string(),
- PLAIN_API_KEY: z.string().optional(),
PAGERDUTY_APP_ID: z.string().optional(),
+ SLACK_SUPPORT_WEBHOOK_URL: z.string().optional(),
},
client: {
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string(),
@@ -57,8 +57,8 @@ export const env = createEnv({
CLICKHOUSE_URL: process.env.CLICKHOUSE_URL,
CLICKHOUSE_USERNAME: process.env.CLICKHOUSE_USERNAME,
CLICKHOUSE_PASSWORD: process.env.CLICKHOUSE_PASSWORD,
- PLAIN_API_KEY: process.env.PLAIN_API_KEY,
PAGERDUTY_APP_ID: process.env.PAGERDUTY_APP_ID,
+ SLACK_SUPPORT_WEBHOOK_URL: process.env.SLACK_SUPPORT_WEBHOOK_URL,
},
skipValidation: true,
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 476114756..daf37968d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -332,9 +332,6 @@ importers:
'@tanstack/react-table':
specifier: 8.10.3
- '@team-plain/typescript-sdk':
- specifier: 4.2.3
- version: 4.2.3
'@tremor/react':
specifier: 3.17.4
@@ -3072,11 +3069,6 @@ packages:
resolution: {integrity: sha512-vwj0jzkHNgY/WvqrNt763QfO3mRHIO1GSFW22scOneI5pcu5sMb/JPN+P+cDPTEXRNPdZCaZ/HicLHZNxbseyA==}
engines: {node: '>=v14'}
- '@graphql-typed-document-node/[email protected]':
- resolution: {integrity: sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==}
- peerDependencies:
- graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0
-
resolution: {integrity: sha512-yMaA/cIsRhGzW3ymCNpdlPcInXcovztlgu/rirThj2b87u3RzWUszliOqZ/pldy7yhmJPS8uwog+kZSTa4A0PQ==}
engines: {node: ^8.13.0 || >=10.10.0}
@@ -4928,9 +4920,6 @@ packages:
peerDependencies:
vue: ^2.7.0 || ^3.0.0
- '@team-plain/[email protected]':
- resolution: {integrity: sha512-aJjN7qXc07t4aJzf55CsiRd6o5OD7hLAEvsG0qMWOSCBq2O802SSucPmHTufAMo5r5/TVLpFVz+aR29nXwW4xg==}
-
'@testing-library/[email protected]':
resolution: {integrity: sha512-wdsYKy5zupPyLCW2Je5DLHSxSfbIp6h80WoHOQc+RPtmPGA52O9x5MJEkv92Sjonpq+poOAtUKhh1kBGAXBrNA==}
engines: {node: '>=18'}
@@ -5396,14 +5385,6 @@ packages:
ajv:
optional: true
- resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==}
- peerDependencies:
- ajv: ^8.0.0
- peerDependenciesMeta:
- ajv:
- optional: true
-
resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==}
peerDependencies:
@@ -5412,9 +5393,6 @@ packages:
ajv:
optional: true
- resolution: {integrity: sha512-oYs1UUtO97ZO2lJ4bwnWeQW8/zvOIQLGKcvPTsWmvc2SYgBb+upuNS5NxoLaMU4h8Ju3Nbj6Cq8mD2LQoqVKFA==}
-
resolution: {integrity: sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==}
@@ -6948,10 +6926,6 @@ packages:
resolution: {integrity: sha512-rEDCuqUQ4tbD78TpzsMtt5OIf0cBCSDWSJtUDaF6JsAh+k0v9r++NzxNEG87oDZx9ZwGhD8DaezR2L/yrw0Jdw==}
engines: {node: '>=10'}
- resolution: {integrity: sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==}
- engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0}
-
resolution: {integrity: sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==}
engines: {node: '>=6.0'}
@@ -12625,10 +12599,6 @@ snapshots:
- encoding
- supports-color
- '@graphql-typed-document-node/[email protected]([email protected])':
- dependencies:
- graphql: 16.8.1
-
dependencies:
'@grpc/proto-loader': 0.7.10
@@ -15045,14 +15015,6 @@ snapshots:
'@tanstack/virtual-core': 3.8.3
vue: 3.4.31([email protected])
- '@team-plain/[email protected]':
- dependencies:
- '@graphql-typed-document-node/core': 3.2.0([email protected])
- ajv: 8.14.0
- ajv-formats: 2.1.1([email protected])
- graphql: 16.8.1
- zod: 3.22.4
-
'@testing-library/[email protected]':
dependencies:
'@babel/code-frame': 7.24.7
@@ -15602,21 +15564,10 @@ snapshots:
optionalDependencies:
ajv: 8.16.0
- optionalDependencies:
- ajv: 8.14.0
-
optionalDependencies:
ajv: 8.16.0
- dependencies:
- fast-deep-equal: 3.1.3
- json-schema-traverse: 1.0.0
- require-from-string: 2.0.2
- uri-js: 4.4.1
-
dependencies:
fast-deep-equal: 3.1.3
@@ -17278,8 +17229,6 @@ snapshots:
chalk: 4.1.2
tinygradient: 1.1.5
-
dependencies:
js-yaml: 3.14.1