Skip to content

Commit a4285df

Browse files
committed
Added welcome email to new users
1 parent f642a46 commit a4285df

File tree

2 files changed

+80
-45
lines changed

2 files changed

+80
-45
lines changed

backend/src/controllers/signupController.ts

+16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from '../helpers/signup';
1111
import { issueTokens, createToken } from '../helpers/auth';
1212
import { INVITED, ACCEPTED } from '../variables';
13+
import axios from 'axios';
1314

1415
/**
1516
* Signup step 1: Initialize account for user under email [email] and send a verification code
@@ -179,6 +180,21 @@ export const completeAccountSignup = async (req: Request, res: Response) => {
179180

180181
token = tokens.token;
181182
refreshToken = tokens.refreshToken;
183+
184+
// sending a welcome email to new users
185+
if (process.env.LOOPS_API_KEY) {
186+
await axios.post("https://app.loops.so/api/v1/events/send", {
187+
"email": email,
188+
"eventName": "Sign Up",
189+
"firstName": firstName,
190+
"lastName": lastName
191+
}, {
192+
headers: {
193+
"Accept": "application/json",
194+
"Authorization": "Bearer " + process.env.LOOPS_API_KEY
195+
},
196+
});
197+
}
182198
} catch (err) {
183199
Sentry.setUser(null);
184200
Sentry.captureException(err);

frontend/pages/signup.tsx

+64-45
Original file line numberDiff line numberDiff line change
@@ -260,46 +260,49 @@ export default function SignUp() {
260260

261261
// Step 1 of the sign up process (enter the email or choose google authentication)
262262
const step1 = (
263-
<div className="bg-bunker w-full max-w-md mx-auto h-7/12 py-8 md:px-6 mx-1 mb-48 md:mb-16 rounded-xl drop-shadow-xl">
264-
<p className="text-4xl font-semibold flex justify-center text-transparent bg-clip-text bg-gradient-to-br from-sky-400 to-primary">
265-
{'Let\''}s get started
266-
</p>
267-
<div className="flex flex-col items-center justify-center w-full md:pb-2 max-h-24 max-w-md mx-auto pt-2">
263+
<div>
264+
<div className="bg-bunker w-full max-w-md mx-auto h-7/12 py-8 md:px-6 mx-1 rounded-xl drop-shadow-xl">
265+
<p className="text-4xl font-semibold flex justify-center text-primary">
266+
{'Let\''}s get started
267+
</p>
268+
<div className="flex items-center justify-center w-5/6 md:w-full m-auto md:p-2 rounded-lg max-h-24 mt-4">
269+
<InputField
270+
label="Email"
271+
onChangeHandler={setEmail}
272+
type="email"
273+
value={email}
274+
placeholder=""
275+
isRequired
276+
error={emailError}
277+
errorText={emailErrorMessage}
278+
autoComplete="username"
279+
/>
280+
</div>
281+
{/* <div className='flex flex-row justify-left mt-4 max-w-md mx-auto'>
282+
<Checkbox className="mr-4"/>
283+
<p className='text-sm'>I do not want to receive emails about Infisical and its products.</p>
284+
</div> */}
285+
<div className="flex flex-col items-center justify-center w-5/6 md:w-full md:p-2 max-h-28 max-w-xs md:max-w-md mx-auto mt-4 md:mt-4 text-sm text-center md:text-left">
286+
<p className="text-gray-400 mt-2 md:mx-0.5">
287+
By creating an account, you agree to our Terms and have read and
288+
acknowledged the Privacy Policy.
289+
</p>
290+
<div className="text-l mt-6 m-2 md:m-8 px-8 py-1 text-lg">
291+
<Button text="Get Started" type="submit" onButtonPressed={emailCheck} size="lg" />
292+
</div>
293+
</div>
294+
</div>
295+
<div className="flex flex-col items-center justify-center w-full md:pb-2 max-w-md mx-auto pt-2 mb-48 md:mb-16 mt-2">
268296
<Link href="/login">
269297
<button type="button" className="w-max pb-3 hover:opacity-90 duration-200">
270-
<u className="font-normal text-md text-sky-500">
298+
<u className="font-normal text-sm text-primary-500">
271299
Have an account? Log in
272300
</u>
273301
</button>
274302
</Link>
275303
</div>
276-
<div className="flex items-center justify-center w-5/6 md:w-full m-auto md:p-2 rounded-lg max-h-24 mt-4">
277-
<InputField
278-
label="Email"
279-
onChangeHandler={setEmail}
280-
type="email"
281-
value={email}
282-
placeholder=""
283-
isRequired
284-
error={emailError}
285-
errorText={emailErrorMessage}
286-
autoComplete="username"
287-
/>
288-
</div>
289-
{/* <div className='flex flex-row justify-left mt-4 max-w-md mx-auto'>
290-
<Checkbox className="mr-4"/>
291-
<p className='text-sm'>I do not want to receive emails about Infisical and its products.</p>
292-
</div> */}
293-
<div className="flex flex-col items-center justify-center w-5/6 md:w-full md:p-2 max-h-28 max-w-xs md:max-w-md mx-auto mt-4 md:mt-4 text-sm text-center md:text-left">
294-
<p className="text-gray-400 mt-2 md:mx-0.5">
295-
By creating an account, you agree to our Terms and have read and
296-
acknowledged the Privacy Policy.
297-
</p>
298-
<div className="text-l mt-6 m-2 md:m-8 px-8 py-1 text-lg">
299-
<Button text="Get Started" type="submit" onButtonPressed={emailCheck} size="lg" />
300-
</div>
301-
</div>
302304
</div>
305+
303306
);
304307

305308
// Step 2 of the signup process (enter the email verification code)
@@ -340,11 +343,11 @@ export default function SignUp() {
340343
<Button text="Verify" onButtonPressed={incrementStep} size="lg" />
341344
</div>
342345
<div className="flex flex-col items-center justify-center w-full max-h-24 max-w-md mx-auto pt-2">
343-
<div className="flex flex-row items-baseline gap-1">
346+
<div className="flex flex-row items-baseline gap-1 text-sm">
344347
<span className="text-gray-400">
345348
Not seeing an email?
346349
</span>
347-
<u className={`font-normal text-sm ${isResendingVerificationEmail ? 'text-gray-400' : 'text-sky-500 hover:opacity-90 duration-200'}`}>
350+
<u className={`font-normal ${isResendingVerificationEmail ? 'text-gray-400' : 'text-primary-500 hover:opacity-90 duration-200'}`}>
348351
<button disabled={isLoading} onClick={resendVerificationEmail}>
349352
{isResendingVerificationEmail ? 'Resending...' : 'Resend'}
350353
</button>
@@ -512,17 +515,33 @@ export default function SignUp() {
512515
It contains your Secret Key which we cannot access or recover for you if
513516
you lose it.
514517
</div>
515-
<div
516-
className="text-l mt-4 text-lg text-gray-400 hover:text-gray-300 duration-200 bg-white/5 px-8 hover:bg-white/10 py-3 rounded-md cursor-pointer"
517-
onClick={() => {
518-
if (localStorage.getItem("projectData.id")) {
519-
router.push("/dashboard/" + localStorage.getItem("projectData.id"));
520-
} else {
521-
router.push("/noprojects")
522-
}
523-
}}
524-
>
525-
Later
518+
<div className="flex flex-col items-center justify-center md:px-4 md:py-5 mt-2 px-2 py-3 max-h-24 max-w-max mx-auto text-lg">
519+
<Button
520+
text="Download PDF"
521+
onButtonPressed={async () => {
522+
await issueBackupKey({
523+
email,
524+
password,
525+
personalName: firstName + ' ' + lastName,
526+
setBackupKeyError,
527+
setBackupKeyIssued
528+
});
529+
router.push('/dashboard/');
530+
}}
531+
size="lg"
532+
/>
533+
{/* <div
534+
className="text-l mt-4 text-lg text-gray-400 hover:text-gray-300 duration-200 bg-white/5 px-8 hover:bg-white/10 py-3 rounded-md cursor-pointer"
535+
onClick={() => {
536+
if (localStorage.getItem("projectData.id")) {
537+
router.push("/dashboard/" + localStorage.getItem("projectData.id"));
538+
} else {
539+
router.push("/noprojects")
540+
}
541+
}}
542+
>
543+
Later
544+
</div> */}
526545
</div>
527546
</div>
528547
);

0 commit comments

Comments
 (0)