-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.sh
More file actions
107 lines (88 loc) · 2.59 KB
/
Copy pathtest-api.sh
File metadata and controls
107 lines (88 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
echo "🧪 Testing Analytics System"
echo "============================"
echo ""
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Test 1: Send events
echo -e "${BLUE}📤 Sending test events...${NC}"
echo ""
# Event 1 - Home page
curl -X POST http://localhost:3000/api/event \
-H "Content-Type: application/json" \
-d '{
"site_id": "site-abc-123",
"event_type": "page_view",
"path": "/",
"user_id": "user-123",
"timestamp": "2025-11-14T10:00:00Z"
}' && echo ""
sleep 0.5
# Event 2 - Pricing page
curl -X POST http://localhost:3000/api/event \
-H "Content-Type: application/json" \
-d '{
"site_id": "site-abc-123",
"event_type": "page_view",
"path": "/pricing",
"user_id": "user-456",
"timestamp": "2025-11-14T10:05:00Z"
}' && echo ""
sleep 0.5
# Event 3 - Blog post
curl -X POST http://localhost:3000/api/event \
-H "Content-Type: application/json" \
-d '{
"site_id": "site-abc-123",
"event_type": "page_view",
"path": "/blog/post-1",
"user_id": "user-123",
"timestamp": "2025-11-14T10:10:00Z"
}' && echo ""
sleep 0.5
# Event 4 - Another pricing view
curl -X POST http://localhost:3000/api/event \
-H "Content-Type: application/json" \
-d '{
"site_id": "site-abc-123",
"event_type": "page_view",
"path": "/pricing",
"user_id": "user-789",
"timestamp": "2025-11-14T10:15:00Z"
}' && echo ""
sleep 0.5
# Event 5 - Different site
curl -X POST http://localhost:3000/api/event \
-H "Content-Type: application/json" \
-d '{
"site_id": "site-xyz-999",
"event_type": "page_view",
"path": "/contact",
"user_id": "user-111",
"timestamp": "2025-11-14T10:20:00Z"
}' && echo ""
echo ""
echo -e "${GREEN}✓ Sent 5 test events${NC}"
echo ""
# Wait for processing
echo -e "${BLUE}⏳ Waiting 3 seconds for processing...${NC}"
sleep 3
echo ""
# Test 2: Get stats
echo -e "${BLUE}📊 Fetching statistics...${NC}"
echo ""
echo "Stats for site-abc-123:"
curl "http://localhost:3000/api/stats?site_id=site-abc-123" | json_pp 2>/dev/null || curl "http://localhost:3000/api/stats?site_id=site-abc-123"
echo ""
echo ""
echo "Stats for site-abc-123 on 2025-11-14:"
curl "http://localhost:3000/api/stats?site_id=site-abc-123&date=2025-11-14" | json_pp 2>/dev/null || curl "http://localhost:3000/api/stats?site_id=site-abc-123&date=2025-11-14"
echo ""
echo ""
echo "Stats for site-xyz-999:"
curl "http://localhost:3000/api/stats?site_id=site-xyz-999" | json_pp 2>/dev/null || curl "http://localhost:3000/api/stats?site_id=site-xyz-999"
echo ""
echo ""
echo -e "${GREEN}✅ Test completed!${NC}"