Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: activate

Nevo David656f29eb34d6
diff --git a/apps/backend/src/api/routes/auth.controller.ts b/apps/backend/src/api/routes/auth.controller.ts
index a154c18e3..4f87d07d6 100644
--- a/apps/backend/src/api/routes/auth.controller.ts
+++ b/apps/backend/src/api/routes/auth.controller.ts
@@ -207,9 +207,10 @@ export class AuthController {
@Post('/activate')
async activate(
@Body('code') code: string,
+ @Body('datafast_visitor_id') datafast_visitor_id: string,
@Res({ passthrough: false }) response: Response
) {
- const activate = await this._authService.activate(code);
+ const activate = await this._authService.activate(code, datafast_visitor_id);
if (!activate) {
return response.status(200).json({ can: false });
}
diff --git a/apps/backend/src/services/auth/auth.service.ts b/apps/backend/src/services/auth/auth.service.ts
index 2a420a4d9..3b639fb6a 100644
--- a/apps/backend/src/services/auth/auth.service.ts
+++ b/apps/backend/src/services/auth/auth.service.ts
@@ -168,7 +168,7 @@ export class AuthService {
userAgent
);
- this._track(providerUser.email, body.datafast_visitor_id).catch(
+ this._track('register', providerUser.email, body.datafast_visitor_id).catch(
(err) => {}
);
@@ -177,7 +177,11 @@ export class AuthService {
return create.users[0].user;
}
- private async _track(email: string, datafast_visitor_id: string) {
+ private async _track(
+ name: string,
+ email: string,
+ datafast_visitor_id: string
+ ) {
if (email && datafast_visitor_id && process.env.DATAFAST_API_KEY) {
try {
await fetch('https://datafa.st/api/v1/goals', {
@@ -188,10 +192,9 @@ export class AuthService {
},
body: JSON.stringify({
datafast_visitor_id: datafast_visitor_id,
- name: 'newsletter_signup',
+ name: name,
metadata: {
- name: 'Elon Musk',
- email: '[email protected]',
+ email,
},
}),
});
@@ -229,7 +232,7 @@ export class AuthService {
return this._userService.updatePassword(user.id, body.password);
}
- async activate(code: string) {
+ async activate(code: string, tracking: string) {
const user = AuthChecker.verifyJWT(code) as {
id: string;
activated: boolean;
@@ -242,6 +245,7 @@ export class AuthService {
}
await this._userService.activateUser(user.id);
user.activated = true;
+ this._track('register', user.email, tracking).catch((err) => {});
await NewsletterService.register(user.email);
return this.jwt(user as any);
}
diff --git a/apps/frontend/src/components/auth/after.activate.tsx b/apps/frontend/src/components/auth/after.activate.tsx
index 9b59ce3d5..ef2dee1f1 100644
--- a/apps/frontend/src/components/auth/after.activate.tsx
+++ b/apps/frontend/src/components/auth/after.activate.tsx
@@ -6,12 +6,14 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { useParams } from 'next/navigation';
import Link from 'next/link';
import { useT } from '@gitroom/react/translation/get.transation.service.client';
+import useCookie from 'react-use-cookie';
export const AfterActivate = () => {
const fetch = useFetch();
const params = useParams();
const [showLoader, setShowLoader] = useState(true);
const run = useRef(false);
const t = useT();
+ const [datafast_visitor_id] = useCookie('datafast_visitor_id');
useEffect(() => {
if (!run.current) {
@@ -26,6 +28,7 @@ export const AfterActivate = () => {
method: 'POST',
body: JSON.stringify({
code: params.code,
+ datafast_visitor_id,
}),
headers: {
'Content-Type': 'application/json',