Skip to content

Commit

Permalink
fix: news letter sending
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Dec 7, 2023
1 parent 9bfb6b9 commit 00eaadf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 43 deletions.
Expand Up @@ -80,6 +80,7 @@ export const authenticationService = {
await sendTelemetry({
user, project: authnResponse.project,
})
await saveNewsLetterSubscriber(user)

return {
...userWithoutPassword,
Expand Down Expand Up @@ -199,6 +200,25 @@ const sendTelemetry = async ({ user, project }: SendTelemetryParams): Promise<vo
}
}

async function saveNewsLetterSubscriber(user: User): Promise<void> {
const isPlatformUserOrNotSubscribed = !isNil(user.platformId) || !user.newsLetter
if (isPlatformUserOrNotSubscribed) {
return
}
try {
const response = await fetch('https://us-central1-activepieces-b3803.cloudfunctions.net/addContact', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: user.email }),
})
return await response.json()
}
catch (error) {
logger.warn(error)
}
}
type SendTelemetryParams = {
user: User
project: Project
Expand Down
1 change: 0 additions & 1 deletion packages/ee/shared/src/index.ts
Expand Up @@ -10,7 +10,6 @@ export * from './lib/referral/referral';
export * from './lib/project-members/project-member-request';
export * from './lib/project-members/project-member';
export * from './lib/flow-templates/flow-templates-requests.ee';
export * from './lib/firebase-auth';
export * from './lib/product-embed/app-credentials/index';
export * from './lib/product-embed/connection-keys/index';
export * from './lib/signing-key'
Expand Down

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions packages/ee/shared/src/lib/firebase-auth/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/ui/common/src/lib/service/authentication.service.ts
Expand Up @@ -102,13 +102,6 @@ export class AuthenticationService {
this.router.navigate(['sign-in']);
}

// TODO - move to a separate service
saveNewsLetterSubscriber(email: string) {
return this.http.post(
'https://us-central1-activepieces-b3803.cloudfunctions.net/addContact',
{ email: email }
);
}
getDecodedToken(): Principal | null {
const token = localStorage.getItem(environment.jwtTokenName);
const decodedToken = this.jwtHelper.decodeToken(token || '');
Expand Down
Expand Up @@ -98,20 +98,6 @@ export class SignUpComponent implements OnInit {
this.authenticationService.saveUser(response);
}
}),
switchMap((response) => {
if (this.registrationForm.controls.newsLetter.value && response) {
return this.authenticationService
.saveNewsLetterSubscriber(request.email)
.pipe(
map(() => response),
catchError((err) => {
console.error(err);
return of(response);
})
);
}
return of(response);
}),
tap((response) => {
if (response && response.body?.status === UserStatus.VERIFIED) {
this.redirect();
Expand Down

0 comments on commit 00eaadf

Please sign in to comment.