Skip to content

Commit

Permalink
feat: add first login flag (#8161)
Browse files Browse the repository at this point in the history
  • Loading branch information
arikchakma authored Feb 3, 2025
1 parent b15bdd5 commit 83e315a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/components/AuthenticationFlow/EmailLoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ export function EmailLoginForm(props: EmailLoginFormProps) {

const currentLocation = window.location.href;
const url = new URL(currentLocation, window.location.origin);
if (response?.isNewUser) {
url.searchParams.set(FIRST_LOGIN_PARAM, '1');
}
url.searchParams.set(FIRST_LOGIN_PARAM, response?.isNewUser ? '1' : '0');
window.location.href = url.toString();
return;
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/AuthenticationFlow/GitHubButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ export function GitHubButton(props: GitHubButtonProps) {
localStorage.removeItem(GITHUB_LAST_PAGE);
setAuthToken(response.token);

if (response?.isNewUser) {
redirectUrl.searchParams.set(FIRST_LOGIN_PARAM, '1');
}
redirectUrl.searchParams.set(
FIRST_LOGIN_PARAM,
response?.isNewUser ? '1' : '0',
);

const shouldTriggerPurchase =
localStorage.getItem(CHECKOUT_AFTER_LOGIN_KEY) !== '0';
Expand Down
7 changes: 4 additions & 3 deletions src/components/AuthenticationFlow/GoogleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ export function GoogleButton(props: GoogleButtonProps) {
redirectUrl = new URL(authRedirectUrl, window.location.origin);
}

if (response?.isNewUser) {
redirectUrl.searchParams.set(FIRST_LOGIN_PARAM, '1');
}
redirectUrl.searchParams.set(
FIRST_LOGIN_PARAM,
response?.isNewUser ? '1' : '0',
);

const shouldTriggerPurchase =
localStorage.getItem(CHECKOUT_AFTER_LOGIN_KEY) !== '0';
Expand Down
7 changes: 4 additions & 3 deletions src/components/AuthenticationFlow/LinkedInButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ export function LinkedInButton(props: LinkedInButtonProps) {
redirectUrl = new URL(authRedirectUrl, window.location.origin);
}

if (response?.isNewUser) {
redirectUrl.searchParams.set(FIRST_LOGIN_PARAM, '1');
}
redirectUrl.searchParams.set(
FIRST_LOGIN_PARAM,
response?.isNewUser ? '1' : '0',
);

const shouldTriggerPurchase =
localStorage.getItem(CHECKOUT_AFTER_LOGIN_KEY) !== '0';
Expand Down
13 changes: 9 additions & 4 deletions src/components/AuthenticationFlow/TriggerVerifyAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useEffect, useState } from 'react';
import Cookies from 'js-cookie';
import { httpPost } from '../../lib/http';
import { FIRST_LOGIN_PARAM, TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt';
import {
FIRST_LOGIN_PARAM,
TOKEN_COOKIE_NAME,
setAuthToken,
} from '../../lib/jwt';
import { Spinner } from '../ReactIcons/Spinner';
import { ErrorIcon2 } from '../ReactIcons/ErrorIcon2';
import { triggerUtmRegistration } from '../../lib/browser.ts';
Expand Down Expand Up @@ -32,9 +36,10 @@ export function TriggerVerifyAccount() {
setAuthToken(response.token);

const url = new URL('/', window.location.origin);
if (response?.isNewUser) {
url.searchParams.set(FIRST_LOGIN_PARAM, '1');
}
url.searchParams.set(
FIRST_LOGIN_PARAM,
response?.isNewUser ? '1' : '0',
);
window.location.href = url.toString();
})
.catch((err) => {
Expand Down

0 comments on commit 83e315a

Please sign in to comment.