Skip to content

Commit edc0aab

Browse files
authored
Merge pull request #28 from bryanwills/dev/advanced-tracking-analytics
feat: Add advanced fingerprint tracking and enhanced analytics dashboard
2 parents d89f0c7 + c8a0185 commit edc0aab

File tree

17 files changed

+2093
-233
lines changed

17 files changed

+2093
-233
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@c15t/react": "^1.4.4",
13+
"@fingerprintjs/fingerprintjs": "^4.6.2",
1314
"@radix-ui/react-accordion": "^1.2.11",
1415
"@radix-ui/react-dialog": "^1.1.14",
1516
"@radix-ui/react-dropdown-menu": "^2.1.15",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/deploy-server.sh

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
#!/bin/bash
2+
3+
# Big Brain Coding - Server-Side Deployment Script
4+
# This script builds and deploys the Next.js application with server-side functionality
5+
# for analytics features that require API routes and dynamic data processing
6+
7+
set -e # Exit on any error
8+
9+
# Configuration
10+
PROJECT_DIR="$(pwd)"
11+
BUILD_DIR=".next"
12+
DEPLOY_DIR="/var/www/bigbraincoding.com/html"
13+
PORT=3000
14+
15+
echo "🚀 Big Brain Coding - Server-Side Deployment"
16+
echo "==========================================="
17+
echo "📁 Project Directory: $PROJECT_DIR"
18+
echo "📦 Build Directory: $BUILD_DIR"
19+
echo "🌐 Deploy Directory: $DEPLOY_DIR"
20+
echo "🔌 Port: $PORT"
21+
echo ""
22+
23+
# Step 1: Install dependencies
24+
echo "🔧 Step 1: Installing dependencies..."
25+
npm install
26+
27+
# Step 2: Build the Next.js application
28+
echo ""
29+
echo "🔨 Step 2: Building Next.js application..."
30+
npm run build
31+
32+
# Step 3: Create backup of current deployment
33+
echo ""
34+
echo "📋 Step 3: Creating backup of current deployment..."
35+
BACKUP_DIR="/tmp/bigbraincoding-backup-$(date +%Y%m%d-%H%M%S)"
36+
BACKUP_ARCHIVE="$BACKUP_DIR.tar.bz2"
37+
if [ -d "$DEPLOY_DIR" ]; then
38+
mkdir -p "$BACKUP_DIR"
39+
cp -r "$DEPLOY_DIR"/* "$BACKUP_DIR/" 2>/dev/null || true
40+
echo "📦 Compressing backup to save disk space..."
41+
tar -cjf "$BACKUP_ARCHIVE" -C "$(dirname "$BACKUP_DIR")" "$(basename "$BACKUP_DIR")"
42+
rm -rf "$BACKUP_DIR"
43+
echo "✅ Compressed backup created at: $BACKUP_ARCHIVE"
44+
else
45+
echo "ℹ️ No existing deployment to backup"
46+
fi
47+
48+
# Step 4: Deploy application files
49+
echo ""
50+
echo "📤 Step 4: Deploying application files..."
51+
52+
# Create deploy directory if it doesn't exist
53+
sudo mkdir -p "$DEPLOY_DIR"
54+
55+
# Copy necessary files for server-side deployment
56+
echo "📁 Copying application files..."
57+
sudo cp -r "$BUILD_DIR" "$DEPLOY_DIR/"
58+
sudo cp package.json "$DEPLOY_DIR/"
59+
sudo cp package-lock.json "$DEPLOY_DIR/"
60+
sudo cp next.config.js "$DEPLOY_DIR/"
61+
sudo cp -r public "$DEPLOY_DIR/"
62+
sudo cp -r src "$DEPLOY_DIR/"
63+
64+
# Step 5: Set proper permissions
65+
echo ""
66+
echo "🔐 Step 5: Setting permissions..."
67+
sudo chown -R $USER:$USER "$DEPLOY_DIR"
68+
sudo chmod -R 755 "$DEPLOY_DIR"
69+
echo "✅ Permissions set"
70+
71+
# Step 6: Install production dependencies in deploy directory
72+
echo ""
73+
echo "📦 Step 6: Installing production dependencies..."
74+
cd "$DEPLOY_DIR"
75+
npm ci --only=production
76+
cd "$PROJECT_DIR"
77+
78+
# Step 7: Create PM2 ecosystem file for process management
79+
echo ""
80+
echo "⚙️ Step 7: Setting up process management..."
81+
cat > "$DEPLOY_DIR/ecosystem.config.js" << EOF
82+
module.exports = {
83+
apps: [{
84+
name: 'bigbraincoding',
85+
script: 'node_modules/next/dist/bin/next',
86+
args: 'start',
87+
cwd: '$DEPLOY_DIR',
88+
instances: 1,
89+
autorestart: true,
90+
watch: false,
91+
max_memory_restart: '1G',
92+
env: {
93+
NODE_ENV: 'production',
94+
PORT: $PORT
95+
}
96+
}]
97+
}
98+
EOF
99+
100+
# Step 8: Stop existing PM2 process if running
101+
echo ""
102+
echo "🛑 Step 8: Managing PM2 processes..."
103+
if command -v pm2 &> /dev/null; then
104+
pm2 stop bigbraincoding 2>/dev/null || true
105+
pm2 delete bigbraincoding 2>/dev/null || true
106+
echo "✅ Stopped existing PM2 process"
107+
else
108+
echo "ℹ️ PM2 not found, installing..."
109+
npm install -g pm2
110+
fi
111+
112+
# Step 9: Start the application with PM2
113+
echo ""
114+
echo "🚀 Step 9: Starting application with PM2..."
115+
cd "$DEPLOY_DIR"
116+
pm2 start ecosystem.config.js
117+
pm2 save
118+
cd "$PROJECT_DIR"
119+
120+
# Step 10: Configure nginx to proxy to the Node.js application
121+
echo ""
122+
echo "🌐 Step 10: Configuring nginx proxy..."
123+
NGINX_CONFIG="/etc/nginx/sites-available/bigbraincoding.com"
124+
sudo tee "$NGINX_CONFIG" > /dev/null << EOF
125+
server {
126+
listen 80;
127+
server_name bigbraincoding.com www.bigbraincoding.com;
128+
129+
location / {
130+
proxy_pass http://localhost:$PORT;
131+
proxy_http_version 1.1;
132+
proxy_set_header Upgrade \$http_upgrade;
133+
proxy_set_header Connection 'upgrade';
134+
proxy_set_header Host \$host;
135+
proxy_set_header X-Real-IP \$remote_addr;
136+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
137+
proxy_set_header X-Forwarded-Proto \$scheme;
138+
proxy_cache_bypass \$http_upgrade;
139+
}
140+
}
141+
EOF
142+
143+
# Enable the site and restart nginx
144+
sudo ln -sf "$NGINX_CONFIG" /etc/nginx/sites-enabled/
145+
sudo nginx -t && sudo systemctl reload nginx
146+
147+
# Step 11: Verify deployment
148+
echo ""
149+
echo "✅ Step 11: Verifying deployment..."
150+
sleep 5 # Give the application time to start
151+
152+
if curl -f http://localhost:$PORT > /dev/null 2>&1; then
153+
echo "✅ Application is running on port $PORT"
154+
echo "✅ Deployment successful!"
155+
echo ""
156+
echo "🌐 Your site should now be live at: https://bigbraincoding.com"
157+
echo "📊 Analytics features are now active!"
158+
echo "🔧 PM2 process: bigbraincoding"
159+
echo "📈 Monitor with: pm2 monit"
160+
else
161+
echo "❌ Error: Application is not responding on port $PORT"
162+
echo "🔍 Check logs with: pm2 logs bigbraincoding"
163+
exit 1
164+
fi
165+
166+
echo ""
167+
echo "🎉 Server-side deployment complete!"
168+
echo ""
169+
echo "📋 Useful commands:"
170+
echo " pm2 status - Check application status"
171+
echo " pm2 logs bigbraincoding - View application logs"
172+
echo " pm2 restart bigbraincoding - Restart application"
173+
echo " pm2 monit - Monitor all processes"

scripts/deploy-simple.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
# Big Brain Coding - Simple Server-Side Deployment
4+
# This script starts the Next.js application with PM2 for analytics features
5+
6+
set -e # Exit on any error
7+
8+
# Configuration
9+
PROJECT_DIR="$(pwd)"
10+
PORT=3000
11+
12+
echo "🚀 Big Brain Coding - Simple Server Deployment"
13+
echo "============================================="
14+
echo "📁 Project Directory: $PROJECT_DIR"
15+
echo "🔌 Port: $PORT"
16+
echo ""
17+
18+
# Step 1: Build the application
19+
echo "🔨 Step 1: Building Next.js application..."
20+
npm run build
21+
22+
# Step 2: Stop existing PM2 process if running
23+
echo ""
24+
echo "🛑 Step 2: Managing PM2 processes..."
25+
pm2 stop bigbraincoding 2>/dev/null || true
26+
pm2 delete bigbraincoding 2>/dev/null || true
27+
echo "✅ Stopped existing PM2 process"
28+
29+
# Step 3: Start the application with PM2
30+
echo ""
31+
echo "🚀 Step 3: Starting application with PM2..."
32+
pm2 start "npm start" --name bigbraincoding --cwd "$PROJECT_DIR"
33+
pm2 save
34+
35+
# Step 4: Configure nginx to proxy to the Node.js application
36+
echo ""
37+
echo "🌐 Step 4: Configuring nginx proxy..."
38+
NGINX_CONFIG="/etc/nginx/sites-available/bigbraincoding.com"
39+
sudo tee "$NGINX_CONFIG" > /dev/null << EOF
40+
server {
41+
listen 80;
42+
server_name bigbraincoding.com www.bigbraincoding.com;
43+
44+
location / {
45+
proxy_pass http://localhost:$PORT;
46+
proxy_http_version 1.1;
47+
proxy_set_header Upgrade \$http_upgrade;
48+
proxy_set_header Connection 'upgrade';
49+
proxy_set_header Host \$host;
50+
proxy_set_header X-Real-IP \$remote_addr;
51+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
52+
proxy_set_header X-Forwarded-Proto \$scheme;
53+
proxy_cache_bypass \$http_upgrade;
54+
}
55+
}
56+
EOF
57+
58+
# Enable the site and restart nginx
59+
sudo ln -sf "$NGINX_CONFIG" /etc/nginx/sites-enabled/
60+
sudo nginx -t && sudo systemctl reload nginx
61+
62+
# Step 5: Verify deployment
63+
echo ""
64+
echo "✅ Step 5: Verifying deployment..."
65+
sleep 5 # Give the application time to start
66+
67+
if curl -f http://localhost:$PORT > /dev/null 2>&1; then
68+
echo "✅ Application is running on port $PORT"
69+
echo "✅ Deployment successful!"
70+
echo ""
71+
echo "🌐 Your site should now be live at: https://bigbraincoding.com"
72+
echo "📊 Analytics features are now active!"
73+
echo "🔧 PM2 process: bigbraincoding"
74+
echo "📈 Monitor with: pm2 monit"
75+
else
76+
echo "❌ Error: Application is not responding on port $PORT"
77+
echo "🔍 Check logs with: pm2 logs bigbraincoding"
78+
exit 1
79+
fi
80+
81+
echo ""
82+
echo "🎉 Server-side deployment complete!"
83+
echo ""
84+
echo "📋 Useful commands:"
85+
echo " pm2 status - Check application status"
86+
echo " pm2 logs bigbraincoding - View application logs"
87+
echo " pm2 restart bigbraincoding - Restart application"
88+
echo " pm2 monit - Monitor all processes"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import FingerprintAnalyticsDashboard from '@/components/analytics/FingerprintAnalyticsDashboard';
2+
3+
// Force dynamic rendering to avoid caching issues
4+
export const dynamic = 'force-dynamic';
5+
6+
export default function FingerprintPage() {
7+
return <FingerprintAnalyticsDashboard />;
8+
}

0 commit comments

Comments
 (0)