export function apiDeveloperFeedbackSurvey(form: FormTs) {
// API & Developer Experience Feedback Survey
// Demonstrates: RatingScale (NPS), MatrixQuestion x2, StarRating x4, Slider,
// CheckboxList, RadioButton, SuggestionChips, dynamic styling, conditional visibility
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Developer Experience Feedback',
computedValue: () => 'Help us build a better developer platform. Your feedback shapes our API roadmap.',
customStyles: {
background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)',
color: '#22d3ee',
padding: '28px',
borderRadius: '12px',
textAlign: 'center',
fontFamily: 'monospace'
}
});
});
// ============================================
// SECTION 1: Overall DX Score
// ============================================
const dxSection = form.addSubform('dxSection', {
title: 'Developer Experience Score',
customStyles: () => {
const score = dxSection.ratingScale('dxScore')?.value();
if (score !== null && score !== undefined) {
if (score >= 9) return { backgroundColor: '#ecfdf5', padding: '16px', borderRadius: '8px' };
if (score >= 7) return { backgroundColor: '#fefce8', padding: '16px', borderRadius: '8px' };
return { backgroundColor: '#fef2f2', padding: '16px', borderRadius: '8px' };
}
return { padding: '16px', border: '2px dashed #e2e8f0', borderRadius: '8px' };
}
});
dxSection.addRow(row => {
row.addRatingScale('dxScore', {
preset: 'nps',
label: 'How likely are you to recommend our API to other developers?',
showCategoryLabel: true,
showSegmentColors: true,
isRequired: true
});
});
dxSection.addRow(row => {
row.addTextPanel('dxCategory', {
computedValue: () => {
const category = dxSection.ratingScale('dxScore')?.npsCategory();
if (category === 'promoter') return '💚 Developer Advocate - Thank you for spreading the word!';
if (category === 'passive') return '💛 Satisfied Developer - What would make us exceptional?';
if (category === 'detractor') return '💔 We want to fix this. Tell us what\'s broken.';
return '';
},
customStyles: () => {
const category = dxSection.ratingScale('dxScore')?.npsCategory();
const base = { textAlign: 'center', padding: '12px', borderRadius: '6px', fontFamily: 'monospace' };
if (category === 'promoter') return { ...base, backgroundColor: '#d1fae5', color: '#065f46' };
if (category === 'passive') return { ...base, backgroundColor: '#fef3c7', color: '#92400e' };
if (category === 'detractor') return { ...base, backgroundColor: '#fee2e2', color: '#991b1b' };
return { display: 'none' };
},
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
});
// ============================================
// SECTION 2: API Quality Assessment
// ============================================
const apiSection = form.addSubform('apiSection', {
title: 'API Quality',
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
apiSection.addRow(row => {
row.addMatrixQuestion('apiQuality', {
label: 'Rate the following aspects of our API:',
rows: [
{ id: 'design', label: 'API design & consistency', isRequired: true },
{ id: 'errors', label: 'Error messages & handling', isRequired: true },
{ id: 'auth', label: 'Authentication flow' },
{ id: 'rate-limits', label: 'Rate limits & quotas' },
{ id: 'versioning', label: 'API versioning' },
{ id: 'performance', label: 'Response times & reliability' }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
apiSection.addRow(row => {
row.addSlider('integrationDifficulty', {
label: 'How difficult was integrating with our API?',
min: 1,
max: 5,
step: 1,
defaultValue: 3,
showValue: true
});
});
apiSection.addRow(row => {
row.addTextPanel('difficultyLabel', {
computedValue: () => {
const val = apiSection.slider('integrationDifficulty')?.value();
const labels: Record<number, string> = {
1: '🚀 Very Easy - Took minutes',
2: '✅ Easy - Straightforward',
3: '🔧 Moderate - Some challenges',
4: '⚠️ Difficult - Significant hurdles',
5: '🔥 Very Difficult - Major struggle'
};
return val ? labels[val] : '';
},
customStyles: {
textAlign: 'center',
fontSize: '14px',
color: '#64748b',
marginTop: '-8px'
}
});
});
// ============================================
// SECTION 3: Documentation & Resources
// ============================================
const docsSection = form.addSubform('docsSection', {
title: 'Documentation & Resources',
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
docsSection.addRow(row => {
row.addStarRating('docsQuality', {
label: 'Documentation quality',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
row.addStarRating('codeExamples', {
label: 'Code examples & snippets',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
});
docsSection.addRow(row => {
row.addStarRating('sdkQuality', {
label: 'SDK/Client library quality',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
row.addStarRating('sandboxQuality', {
label: 'Sandbox/Testing environment',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
});
docsSection.addRow(row => {
row.addCheckboxList('docsPainPoints', {
label: 'Which documentation issues have you encountered? (Select all that apply)',
options: [
{ id: 'outdated', name: 'Outdated information' },
{ id: 'incomplete', name: 'Missing or incomplete sections' },
{ id: 'hard-to-find', name: 'Hard to find what I need' },
{ id: 'no-examples', name: 'Lack of code examples' },
{ id: 'wrong-examples', name: 'Code examples don\'t work' },
{ id: 'confusing', name: 'Confusing or unclear language' },
{ id: 'no-search', name: 'Poor search functionality' },
{ id: 'none', name: 'No issues - docs are great!' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 4: Development Environment
// ============================================
const envSection = form.addSubform('envSection', {
title: 'Your Development Environment',
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
envSection.addRow(row => {
row.addRadioButton('primaryLanguage', {
label: 'What\'s your primary programming language?',
options: [
{ id: 'javascript', name: 'JavaScript/TypeScript' },
{ id: 'python', name: 'Python' },
{ id: 'java', name: 'Java/Kotlin' },
{ id: 'csharp', name: 'C#/.NET' },
{ id: 'go', name: 'Go' },
{ id: 'ruby', name: 'Ruby' },
{ id: 'php', name: 'PHP' },
{ id: 'other', name: 'Other' }
],
orientation: 'horizontal'
});
});
envSection.addRow(row => {
row.addSuggestionChips('useCase', {
label: 'What are you building? (Select all that apply)',
suggestions: [
{ id: 'web-app', name: 'Web Application' },
{ id: 'mobile-app', name: 'Mobile App' },
{ id: 'backend', name: 'Backend Service' },
{ id: 'automation', name: 'Automation/Scripts' },
{ id: 'integration', name: 'Third-party Integration' },
{ id: 'poc', name: 'Proof of Concept' }
],
alignment: 'center'
});
});
// ============================================
// SECTION 5: Support Experience
// ============================================
const supportSection = form.addSubform('supportSection', {
title: 'Developer Support',
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
supportSection.addRow(row => {
row.addRadioButton('contactedSupport', {
label: 'Have you contacted developer support?',
options: [
{ id: 'yes', name: 'Yes' },
{ id: 'no', name: 'No' }
],
orientation: 'horizontal'
});
});
supportSection.addRow(row => {
row.addMatrixQuestion('supportQuality', {
label: 'Rate your support experience:',
rows: [
{ id: 'response-time', label: 'Response time' },
{ id: 'knowledge', label: 'Technical knowledge' },
{ id: 'resolution', label: 'Problem resolution' },
{ id: 'communication', label: 'Communication clarity' }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
striped: true,
isVisible: () => supportSection.radioButton('contactedSupport')?.value() === 'yes'
});
});
// ============================================
// SECTION 6: Feedback & Suggestions
// ============================================
const feedbackSection = form.addSubform('feedbackSection', {
title: 'Your Suggestions',
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
feedbackSection.addSpacer();
feedbackSection.addRow(row => {
row.addTextarea('apiImprovements', {
label: () => {
const category = dxSection.ratingScale('dxScore')?.npsCategory();
if (category === 'detractor') return 'What\'s the #1 thing we need to fix?';
if (category === 'passive') return 'What would make our API exceptional?';
return 'Any suggestions for improvement?';
},
placeholder: 'Be specific - we read every response!',
rows: 3
});
});
feedbackSection.addRow(row => {
row.addTextarea('featureRequest', {
label: 'Any features or endpoints you wish we had?',
placeholder: 'Describe your use case...',
rows: 2
});
});
// ============================================
// SUMMARY SECTION
// ============================================
const summarySection = form.addSubform('summary', {
title: 'DX Feedback Summary',
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const dxScore = dxSection.ratingScale('dxScore')?.value();
const category = dxSection.ratingScale('dxScore')?.npsCategory();
const docsRating = docsSection.starRating('docsQuality')?.value();
const codeExamples = docsSection.starRating('codeExamples')?.value();
const difficulty = apiSection.slider('integrationDifficulty')?.value();
const language = envSection.radioButton('primaryLanguage')?.value();
if (!dxScore) return 'Complete the survey to see your summary.';
let emoji = category === 'promoter' ? '💚' : category === 'passive' ? '💛' : '💔';
let summary = `${emoji} Developer Experience Summary\n`;
summary += `${'═'.repeat(35)}\n\n`;
summary += `🎯 DX Score: ${dxScore}/10 (${category?.charAt(0).toUpperCase()}${category?.slice(1)})\n`;
if (difficulty) {
const diffLabels = ['', 'Very Easy', 'Easy', 'Moderate', 'Difficult', 'Very Difficult'];
summary += `⚡ Integration: ${diffLabels[difficulty]}\n`;
}
if (docsRating) summary += `📚 Docs: ${docsRating}/5 stars\n`;
if (codeExamples) summary += `💻 Examples: ${codeExamples}/5 stars\n`;
if (language) summary += `\n🔧 Language: ${language}`;
return summary;
},
customStyles: () => {
const category = dxSection.ratingScale('dxScore')?.npsCategory();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (category === 'promoter') {
return { ...baseStyles, backgroundColor: '#ecfdf5', borderLeft: '4px solid #10b981' };
} else if (category === 'passive') {
return { ...baseStyles, backgroundColor: '#fefce8', borderLeft: '4px solid #eab308' };
} else if (category === 'detractor') {
return { ...baseStyles, backgroundColor: '#fef2f2', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#f8fafc' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Developer Feedback',
isVisible: () => dxSection.ratingScale('dxScore')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank you for your developer feedback!',
message: 'Your insights help us build a better developer experience. We review every response and prioritize improvements based on your feedback. Happy coding! 🚀'
});
}