feat: Add Google Analytics integration and fix anonymous tracking
- Add Google Analytics tracking (G-ZDZ26XYN2P) to frontend - Create comprehensive analytics utility with event tracking - Track URL submissions, analysis results, and user authentication - Add route tracking for SPA navigation - Fix CORS configuration to support both localhost and production - Fix home page tracking form to display results instead of auto-redirect - Add service management scripts for easier deployment - Update database migrations for enhanced analysis features Key Features: - Anonymous and authenticated user tracking - SSL/SEO/Security analysis event tracking - Error tracking for debugging - Page view tracking for SPA routes - Multi-origin CORS support for development and production
This commit is contained in:
68
start-services.sh
Executable file
68
start-services.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# URL Tracker Tool V2 - Service Startup Script
|
||||
# This script starts both API and Frontend services
|
||||
|
||||
set -e
|
||||
|
||||
# Environment variables
|
||||
export NODE_ENV="production"
|
||||
export PORT=3334
|
||||
export CORS_ORIGIN="https://urltrackertool.com"
|
||||
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/redirect_intelligence_v2?schema=public"
|
||||
export JWT_SECRET="J9k2L7mP4nQ8vX3w6Z9c2F5h8K1m4P7r0T3w6Y9b2E5g8J1l4O7q0S3v6Z9c2F5h"
|
||||
|
||||
# Change to app directory
|
||||
cd /root/catch_redirect
|
||||
|
||||
# Log startup
|
||||
echo "$(date): Starting URL Tracker Tool V2 services..." >> /var/log/catch-redirect.log
|
||||
|
||||
# Kill any existing processes
|
||||
pkill -f "node dist/index.js" || true
|
||||
pkill -f "npx serve" || true
|
||||
sleep 2
|
||||
|
||||
# Start API service
|
||||
echo "$(date): Starting API service on port $PORT..." >> /var/log/catch-redirect.log
|
||||
cd /root/catch_redirect/apps/api
|
||||
nohup node dist/index.js >> /var/log/catch-redirect-api.log 2>&1 &
|
||||
API_PID=$!
|
||||
echo "$(date): API service started with PID $API_PID" >> /var/log/catch-redirect.log
|
||||
|
||||
# Wait for API to be ready
|
||||
sleep 5
|
||||
|
||||
# Start Frontend service
|
||||
echo "$(date): Starting Frontend service on port 3000..." >> /var/log/catch-redirect.log
|
||||
cd /root/catch_redirect/apps/web
|
||||
nohup serve dist -l 3000 >> /var/log/catch-redirect-frontend.log 2>&1 &
|
||||
FRONTEND_PID=$!
|
||||
echo "$(date): Frontend service started with PID $FRONTEND_PID" >> /var/log/catch-redirect.log
|
||||
|
||||
# Save PIDs for monitoring
|
||||
echo "$API_PID" > /var/run/catch-redirect-api.pid
|
||||
echo "$FRONTEND_PID" > /var/run/catch-redirect-frontend.pid
|
||||
|
||||
# Wait and monitor
|
||||
sleep 3
|
||||
|
||||
# Check if services are running
|
||||
if curl -s http://localhost:3334/health > /dev/null; then
|
||||
echo "$(date): API service health check passed" >> /var/log/catch-redirect.log
|
||||
else
|
||||
echo "$(date): ERROR - API service health check failed" >> /var/log/catch-redirect.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if curl -s http://localhost:3000 > /dev/null; then
|
||||
echo "$(date): Frontend service health check passed" >> /var/log/catch-redirect.log
|
||||
else
|
||||
echo "$(date): ERROR - Frontend service health check failed" >> /var/log/catch-redirect.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$(date): All services started successfully" >> /var/log/catch-redirect.log
|
||||
|
||||
# Keep the script running to maintain the service
|
||||
wait
|
||||
Reference in New Issue
Block a user