feat: analtics

This commit is contained in:
karishmas6
2024-10-28 03:05:10 +05:30
parent 29137c9845
commit f06254c688

View File

@@ -6,6 +6,7 @@ import { hashPassword, comparePassword } from '../utils/auth';
import { requireSignIn } from '../middlewares/auth';
import { genAPIKey } from '../utils/api';
import { google } from 'googleapis';
import captureServerAnalytics from "../utils/analytics"
export const router = Router();
interface AuthenticatedRequest extends Request {
@@ -31,6 +32,15 @@ router.post('/register', async (req, res) => {
res.cookie('token', token, {
httpOnly: true
})
captureServerAnalytics.capture({
distinctId: user.id,
event: 'maxun-oss-user-registered',
properties: {
email: user.email,
userId: user.id,
registeredAt: new Date().toISOString()
}
})
res.json(user)
} catch (error: any) {
res.status(500).send(`Could not register user - ${error.message}`)