Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d4586f3a8 | |||
| bf573d36d2 | |||
| 77cb568062 | |||
| 2e79c71394 | |||
| 2bcac58959 | |||
| ebea3ed11d | |||
| a6e5ecc1d9 |
154
simulate_user_activity.js
Normal file
154
simulate_user_activity.js
Normal file
@@ -0,0 +1,154 @@
|
||||
const BASE_URL = 'http://localhost:3000/api/track-search';
|
||||
|
||||
const casualSearchTerms = [
|
||||
'travel ideas',
|
||||
'vacation spots',
|
||||
'cheap flights',
|
||||
'hotels',
|
||||
'trip planner',
|
||||
'how to plan a trip',
|
||||
'holiday packages'
|
||||
];
|
||||
|
||||
const highIntentSearchTerms = [
|
||||
'ItineraryGenie pricing',
|
||||
'ItineraryGenie features',
|
||||
'ItineraryGenie vs competitors',
|
||||
'book luxury hotels Paris August 2024',
|
||||
'AI trip planner reviews',
|
||||
'best itinerary generator',
|
||||
'ItineraryGenie demo request'
|
||||
];
|
||||
|
||||
const casualPageViews = [
|
||||
'/',
|
||||
'/about',
|
||||
'/blog',
|
||||
'/contact'
|
||||
];
|
||||
|
||||
const highIntentPageViews = [
|
||||
'/',
|
||||
'/#features',
|
||||
'/#how-it-works',
|
||||
'/#use-cases',
|
||||
'/#project-insights',
|
||||
'/#contact',
|
||||
'/pricing'
|
||||
];
|
||||
|
||||
const getRandomItem = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
||||
const getRandomDelay = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
||||
async function sendData(endpoint, payload) {
|
||||
try {
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
console.log(`Successfully sent data to ${endpoint}:`, payload);
|
||||
} else {
|
||||
console.error(`Failed to send data to ${endpoint}. Status: ${response.status}`, payload);
|
||||
const errorText = await response.text();
|
||||
console.error('Error response:', errorText);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error sending data to ${endpoint}:`, error, payload);
|
||||
}
|
||||
}
|
||||
|
||||
async function simulateCasualUser(userId) {
|
||||
console.log(`[Casual User ${userId}] Starting casual browsing session.`);
|
||||
const sessionDuration = getRandomDelay(60000, 180000); // 1-3 minutes
|
||||
const startTime = Date.now();
|
||||
|
||||
while (Date.now() - startTime < sessionDuration) {
|
||||
const actionType = Math.random();
|
||||
if (actionType < 0.6) { // 60% chance of a page view
|
||||
const pagePath = getRandomItem(casualPageViews);
|
||||
const payload = {
|
||||
userId,
|
||||
timestamp: new Date().toISOString(),
|
||||
eventType: 'pageView',
|
||||
pagePath: pagePath
|
||||
};
|
||||
await sendData(BASE_URL.replace('/track-search', '/track-pageview'), payload); // Assuming a separate pageview endpoint
|
||||
console.log(`[Casual User ${userId}] Viewed page: ${pagePath}`);
|
||||
} else { // 40% chance of a search
|
||||
const searchTerm = getRandomItem(casualSearchTerms);
|
||||
const payload = {
|
||||
userId,
|
||||
timestamp: new Date().toISOString(),
|
||||
query: searchTerm,
|
||||
intent: 'casual'
|
||||
};
|
||||
await sendData(BASE_URL, payload);
|
||||
console.log(`[Casual User ${userId}] Searched for: "${searchTerm}"`);
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, getRandomDelay(5000, 15000))); // 5-15 second delay between actions
|
||||
}
|
||||
console.log(`[Casual User ${userId}] Casual browsing session ended.`);
|
||||
}
|
||||
|
||||
async function simulateHighIntentUser(userId) {
|
||||
console.log(`[High-Intent User ${userId}] Starting high-intent browsing session.`);
|
||||
const sessionDuration = getRandomDelay(180000, 300000); // 3-5 minutes
|
||||
const startTime = Date.now();
|
||||
|
||||
while (Date.now() - startTime < sessionDuration) {
|
||||
const actionType = Math.random();
|
||||
if (actionType < 0.4) { // 40% chance of a page view
|
||||
const pagePath = getRandomItem(highIntentPageViews);
|
||||
const payload = {
|
||||
userId,
|
||||
timestamp: new Date().toISOString(),
|
||||
eventType: 'pageView',
|
||||
pagePath: pagePath
|
||||
};
|
||||
await sendData(BASE_URL.replace('/track-search', '/track-pageview'), payload); // Assuming a separate pageview endpoint
|
||||
console.log(`[High-Intent User ${userId}] Viewed page: ${pagePath}`);
|
||||
} else { // 60% chance of a search
|
||||
const searchTerm = getRandomItem(highIntentSearchTerms);
|
||||
const payload = {
|
||||
userId,
|
||||
timestamp: new Date().toISOString(),
|
||||
query: searchTerm,
|
||||
intent: 'high-intent'
|
||||
};
|
||||
await sendData(BASE_URL, payload);
|
||||
console.log(`[High-Intent User ${userId}] Searched for: "${searchTerm}"`);
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, getRandomDelay(3000, 8000))); // 3-8 second delay between actions
|
||||
}
|
||||
console.log(`[High-Intent User ${userId}] High-intent browsing session ended.`);
|
||||
}
|
||||
|
||||
async function startSimulation(numCasualUsers = 2, numHighIntentUsers = 1) {
|
||||
console.log(`Starting simulation with ${numCasualUsers} casual users and ${numHighIntentUsers} high-intent users.`);
|
||||
const userPromises = [];
|
||||
|
||||
for (let i = 0; i < numCasualUsers; i++) {
|
||||
const userId = `casual-${Math.random().toString(36).substring(2, 9)}`;
|
||||
userPromises.push(simulateCasualUser(userId));
|
||||
await new Promise(resolve => setTimeout(resolve, getRandomDelay(1000, 5000))); // Stagger user starts
|
||||
}
|
||||
|
||||
for (let i = 0; i < numHighIntentUsers; i++) {
|
||||
const userId = `high-intent-${Math.random().toString(36).substring(2, 9)}`;
|
||||
userPromises.push(simulateHighIntentUser(userId));
|
||||
await new Promise(resolve => setTimeout(resolve, getRandomDelay(1000, 5000))); // Stagger user starts
|
||||
}
|
||||
|
||||
await Promise.all(userPromises);
|
||||
console.log('All user simulations completed.');
|
||||
}
|
||||
|
||||
// Run the simulation
|
||||
startSimulation(3, 2); // Simulate 3 casual users and 2 high-intent users
|
||||
@@ -6,23 +6,23 @@ import "@/lib/gsap-setup";
|
||||
import { ServiceWrapper } from "@/components/ServiceWrapper";
|
||||
import Tag from "@/tag/Tag";
|
||||
import { getVisualEditScript } from "@/utils/visual-edit-script";
|
||||
import { Public_Sans } from "next/font/google";
|
||||
import { Poppins } from "next/font/google";
|
||||
|
||||
const halant = Halant({
|
||||
variable: "--font-halant",
|
||||
subsets: ["latin"],
|
||||
weight: ["300", "400", "500", "600", "700"],
|
||||
});
|
||||
|
||||
const inter = Inter({
|
||||
variable: "--font-inter",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'ItineraryGenie: AI-Powered Spreadsheet Planner & Reservation System',
|
||||
description: 'An intelligent spreadsheet planner and reservation system leveraging custom algorithms (QuickSort, Binary Search, Hash Maps) and Gemini 2.5 Flash API for efficient itinerary and budget management, designed for academic and personal projects.',
|
||||
};
|
||||
|
||||
|
||||
const poppins = Poppins({
|
||||
variable: "--font-poppins",
|
||||
subsets: ["latin"],
|
||||
weight: ["100", "200", "300", "400", "500", "600", "700", "800", "900"],
|
||||
});
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
@@ -31,9 +31,7 @@ export default function RootLayout({
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<ServiceWrapper>
|
||||
<body
|
||||
className={`${halant.variable} ${inter.variable} antialiased`}
|
||||
>
|
||||
<body className={`${poppins.variable} antialiased`}>
|
||||
<Tag />
|
||||
{children}
|
||||
<script
|
||||
|
||||
@@ -11,7 +11,7 @@ html {
|
||||
body {
|
||||
background-color: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: var(--font-inter-tight), sans-serif;
|
||||
font-family: var(--font-poppins), sans-serif;
|
||||
position: relative;
|
||||
min-height: 100vh;
|
||||
overscroll-behavior: none;
|
||||
@@ -24,5 +24,5 @@ h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-family: var(--font-inter-tight), sans-serif;
|
||||
font-family: var(--font-poppins), sans-serif;
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
--background: #f6f0e9;
|
||||
--card: #efe7dd;
|
||||
--foreground: #2b180a;
|
||||
--primary-cta: #2b180a;
|
||||
--primary-cta: #0a162b;
|
||||
--primary-cta-text: #f6f0e9;
|
||||
--secondary-cta: #efe7dd;
|
||||
--secondary-cta-text: #2b180a;
|
||||
--accent: #94877c;
|
||||
--background-accent: #afa094;
|
||||
--background-accent: #969db0;
|
||||
|
||||
/* text sizing - set by ThemeProvider */
|
||||
/* --text-2xs: clamp(0.465rem, 0.62vw, 0.62rem);
|
||||
|
||||
Reference in New Issue
Block a user