Skip to content

Commit 8053c64

Browse files
committed
add slack growth channel webhook
1 parent f13cb02 commit 8053c64

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.env.sample

+2
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ AWS_S3_DS_KEYS_SECRET_ACCESS_KEY=
5454
AWS_S3_DS_KEYS_REGION=us-east-1
5555

5656
NEXT_PUBLIC_ENABLE_FULLSTORY=0
57+
58+
SLACK_GROWTH_CHANNEL_WEBHOOK=

lib/services.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ export const intercomAccessToken = process.env.INTERCOM_ACCESS_TOKEN;
88

99
export const segmentPublicKey = process.env.NEXT_PUBLIC_SEGMENT_PUBLIC_KEY;
1010
export const segmentWriteKey = process.env.SEGMENT_WRITE_KEY;
11+
12+
export const slackGrowthChannelWebhook = process.env.SLACK_GROWTH_CHANNEL_WEBHOOK;

pages/api/auth/register.ts

+26
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// import { Client } from "intercom-client";
33
import { createUser, hashPassword } from "@/features/auth";
44
// import { intercomAccessToken } from "@/lib/services";
5+
import { isString } from "lodash"
56
import { schema } from "@/features/auth/signupSchema";
67
import { serverSegment } from "@/lib/track";
8+
import { slackGrowthChannelWebhook } from "@/lib/services"
79
import { withMiddlewares } from "@/features/api/middleware";
810
import ApiResponse from "@/features/api/ApiResponse";
911
import email from "@/lib/email";
@@ -72,6 +74,30 @@ const handler = async (
7274
// } as any);
7375
// }
7476

77+
let identifier = payload.email
78+
79+
if (payload.firstName || payload.lastName) {
80+
identifier += ` ${payload.firstName} ${payload.lastName}`
81+
}
82+
83+
if (payload.organization) {
84+
identifier += ` - ${payload.organization}`
85+
}
86+
87+
if (payload.lastKnownTimezone) {
88+
identifier += ` (${payload.lastKnownTimezone})`
89+
}
90+
91+
if (isString(slackGrowthChannelWebhook)) {
92+
await fetch(slackGrowthChannelWebhook, {
93+
method: 'POST',
94+
body: JSON.stringify({
95+
text: `${identifier} signed up as a new user on basetool.io`,
96+
}),
97+
headers: { "Content-Type": "application/json" },
98+
})
99+
}
100+
75101
await email.send({
76102
77103
subject: "New user signup",

0 commit comments

Comments
 (0)