-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeedback_test.py
More file actions
executable file
·233 lines (207 loc) · 11.1 KB
/
feedback_test.py
File metadata and controls
executable file
·233 lines (207 loc) · 11.1 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/usr/bin/env python3
"""
╔═══════════════════════════════════════════════════════════════════════════════╗
║ ║
║ ███████╗███████╗███████╗██████╗ ██████╗ █████╗ ██████╗██╗ ██╗ ║
║ ██╔════╝██╔════╝██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██╔╝ ║
║ █████╗ █████╗ █████╗ ██║ ██║██████╔╝███████║██║ █████╔╝ ║
║ ██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║██╔══██╗██╔══██║██║ ██╔═██╗ ║
║ ██║ ███████╗███████╗██████╔╝██████╔╝██║ ██║╚██████╗██║ ██╗ ║
║ ╚═╝ ╚══════╝╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ║
║ ║
║ ██████╗ ██╗ ██╗██╗ ███████╗███████╗ ║
║ ██╔══██╗██║ ██║██║ ██╔════╝██╔════╝ ║
║ ██████╔╝██║ ██║██║ ███████╗█████╗ ║
║ ██╔═══╝ ██║ ██║██║ ╚════██║██╔══╝ ║
║ ██║ ╚██████╔╝███████╗███████║███████╗ ║
║ ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚══════╝ ║
║ ║
╠═══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ Production API Test Script v1.0 ║
║ Test your Feedback Pulse API integration with ease ║
║ ║
╠═══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ 📍 LINKS ║
║ ───────────────────────────────────────────────────────────────────────── ║
║ 🌐 Dashboard: https://fpulse.app/dashboard ║
║ 📚 API Docs: https://fpulse.app/docs ║
║ 🔑 Get API Key: https://fpulse.app/dashboard/projects ║
║ 📊 View Feedback: https://fpulse.app/dashboard/feedbacks ║
║ 💬 Support: support@fpulse.app ║
║ ║
╠═══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ ⚡ QUICK START ║
║ ───────────────────────────────────────────────────────────────────────── ║
║ 1. Get your API key from the Projects page (starts with 'fp_') ║
║ 2. Run this script: python test_prod_feedback.py ║
║ 3. Follow the interactive prompts ║
║ 4. Check your dashboard to see the feedback! ║
║ ║
╠═══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ 📦 SUPPORTED PLATFORMS: iOS | Android | Web | Desktop ║
║ 🔄 ENVIRONMENTS: Production | Development ║
║ 📈 SENTIMENTS: Positive | Negative ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════════╝
"""
import requests
import json
# Production URL
API_URL = "https://fpulse.app/api/v1/feedback"
# Default metadata by app type
DEFAULT_METADATA = {
"ios": {
"device_model": "iPhone 15 Pro",
"os_version": "iOS 17.2",
"locale": "en_US",
"timezone": "America/New_York",
"is_premium": False,
"session_duration": 125
},
"android": {
"device_model": "Pixel 8",
"os_version": "Android 14",
"locale": "en_US",
"timezone": "America/New_York",
"is_premium": False,
"session_duration": 125
},
"web": {
"browser": "Chrome 120",
"os": "macOS 14.2",
"screen_resolution": "1920x1080",
"locale": "en_US",
"timezone": "America/New_York",
"is_premium": False
},
"desktop": {
"os": "macOS 14.2",
"arch": "arm64",
"locale": "en_US",
"timezone": "America/New_York",
"is_premium": False
},
"other": {
"locale": "en_US",
"timezone": "America/New_York"
}
}
def main():
print("=" * 50)
print("Feedback Pulse - Production API Test")
print("=" * 50)
print()
# Get API key
api_key = input("API Key (required): ").strip()
if not api_key:
print("Error: API key is required")
return
if not api_key.startswith('fp_'):
print("Warning: API key should start with 'fp_'")
confirm = input("Continue anyway? (y/n): ").strip().lower()
if confirm != 'y':
return
print()
# Get sentiment
while True:
sentiment = input("Sentiment (p=positive, n=negative): ").strip().lower()
if sentiment in ['p', 'positive']:
sentiment = 'positive'
break
elif sentiment in ['n', 'negative']:
sentiment = 'negative'
break
print("Please enter 'p' for positive or 'n' for negative")
# Get comment
comment = input("Comment (press Enter to skip): ").strip()
# Get app version
app_version = input("App version [1.0.0]: ").strip() or "1.0.0"
# Get app type
print("App types: ios, android, web, desktop, other")
app_type = input("App type [ios]: ").strip().lower() or "ios"
if app_type not in ['ios', 'android', 'web', 'desktop', 'other']:
print(f"Invalid app type, using 'ios'")
app_type = 'ios'
# Get environment
print("Environments: production, development")
environment = input("Environment [production]: ").strip().lower() or "production"
if environment not in ['production', 'development']:
print(f"Invalid environment, using 'production'")
environment = 'production'
# Get screen ID
screen_id = input("Screen ID (press Enter to skip): ").strip()
# Get user ID
user_id = input("User ID (press Enter to skip): ").strip()
# Get metadata
print()
default_meta = DEFAULT_METADATA.get(app_type, {})
print(f"Default metadata for {app_type}:")
print(json.dumps(default_meta, indent=2))
print()
use_defaults = input("Use default metadata? (y/n) [y]: ").strip().lower()
if use_defaults == 'n':
metadata = {}
print("Enter custom metadata key-value pairs (empty key to finish):")
while True:
key = input(" Key: ").strip()
if not key:
break
value = input(" Value: ").strip()
# Try to parse as JSON for bools/numbers
try:
value = json.loads(value)
except:
pass
metadata[key] = value
if not metadata:
print("No metadata entered.")
else:
metadata = default_meta
print("Using default metadata.")
# Build payload
payload = {
"sentiment": sentiment,
"app_version": app_version,
"app_type": app_type,
"environment": environment
}
if comment:
payload["comment"] = comment
if screen_id:
payload["screen_id"] = screen_id
if user_id:
payload["user_id"] = user_id
if metadata:
payload["metadata"] = metadata
print()
print("-" * 50)
print("Sending request...")
print(f"URL: {API_URL}")
print(f"Payload: {json.dumps(payload, indent=2)}")
print("-" * 50)
# Send request
try:
response = requests.post(
API_URL,
json=payload,
headers={
"X-API-Key": api_key,
"Content-Type": "application/json"
}
)
print()
print(f"Status Code: {response.status_code}")
try:
print(f"Response: {json.dumps(response.json(), indent=2)}")
except:
print(f"Response: {response.text}")
except requests.exceptions.ConnectionError:
print("Error: Could not connect to the API. Check your internet connection.")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()