(feedback: string)
| 9 | * Send feedback to the promptfoo API |
| 10 | */ |
| 11 | export async function sendFeedback(feedback: string) { |
| 12 | if (!feedback.trim()) { |
| 13 | return; |
| 14 | } |
| 15 | |
| 16 | try { |
| 17 | const resp = await fetchWithProxy('https://api.promptfoo.dev/api/feedback', { |
| 18 | method: 'POST', |
| 19 | headers: { |
| 20 | 'Content-Type': 'application/json', |
| 21 | }, |
| 22 | body: JSON.stringify({ |
| 23 | message: feedback, |
| 24 | }), |
| 25 | }); |
| 26 | |
| 27 | if (resp.ok) { |
| 28 | logger.info(chalk.green('Feedback sent. Thank you!')); |
| 29 | } else { |
| 30 | logger.info( |
| 31 | chalk.yellow('Failed to send feedback. Please try again or open an issue on GitHub.'), |
| 32 | ); |
| 33 | } |
| 34 | } catch { |
| 35 | logger.error('Network error while sending feedback'); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Gather and send user feedback |
no test coverage detected
searching dependent graphs…